flat assembler
Message board for the users of flat assembler.

Index > Windows > Winsock programming and FASM

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 05 Feb 2006, 04:33
Besides those tutorials for masm syntax and the example at FASM page, is there some good tutorial and simple code examples for winsock programming with FASM?

Thanks

[EDIT]
With trial and error, I got this simple server working when I connect throught telnet:
Code:
;begin
format PE console ;just to see the console and know if app is still running
include '%fasminc%\win32ax.inc'
main:
;code
invoke WSAStartup,0101h,wsa
invoke socket,AF_INET,SOCK_STREAM,0
mov [sock],eax
mov eax,23
xchg ah,al ;Got it from quenatton example, but I don't understand this well, except that is exchanges ah and al, but for what?
mov [saddr.sin_port],ax
mov [saddr.sin_addr],0 ;Here I put 0 so any IP will be accepted, but for the client part I don't know how to use IP address. In what format should it be passed to sin_addr? Could you give me a example please? (not that that comes with quenatton, but something simple like IP number stored somewhere with db or dd, I don't know...)
mov [saddr.sin_family],AF_INET
invoke bind,[sock],saddr,sizeof.sockaddr
invoke listen,[sock],1
invoke accept,[sock],0,0
mov [sock2],eax
invoke send,[sock2],msg,endmsg-msg,0
invoke closesocket,[sock2]
invoke closesocket,[sock]
ret
;end of code

;data
wsa WSADATA
sock dd 0
sock2 dd 0
saddr sockaddr_in
msg db 'hi',0
endmsg:
;end of data
.end main
;eof
    


Thanks again!
Post 05 Feb 2006, 04:33
View user's profile Send private message Reply with quote
aseptik



Joined: 25 Sep 2005
Posts: 4
Location: Croatia
aseptik 05 Feb 2006, 11:37
Well I've done a simple client/server for Linux few days ago, also posted full source on this board so you can look at it in Linux thread, with title problems with sockets. It's not much different than winsock.
Also you can try this site also providing source for simple client/server: http://home.no/ruun/fasm/index.htm
Post 05 Feb 2006, 11:37
View user's profile Send private message Reply with quote
mathi



Joined: 29 Mar 2004
Posts: 4
Location: Chennai, India
mathi 05 Feb 2006, 12:34
I have coded a LAN chat application (but in nasm).

http://www.softpedia.com/get/Internet/Chat/LAN-Messaging-Clients/PEChat.shtml

regards,
Mathi.[/url]
Post 05 Feb 2006, 12:34
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 05 Feb 2006, 17:11
Thanks aseptik!! Your Simple Server and Simple Client examples were exactly what I needed. A very well coded simple example! Very Happy
mathi, I will take a look at youu program tool, it's nasm, but seens pretty complete.

Wow! FASM is great! While socket programming with MASM was so complicated, I think FASM is even easier than C.
And with the help of FASM's macros one can do multi-platform programming by simply using macros and defining symbols that will do the compilation for each platform.
I'll sticky with FASM by now and forget HLL's for a while... Razz
Post 05 Feb 2006, 17:11
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 05 Feb 2006, 19:31
OzzY wrote:
And with the help of FASM's macros one can do multi-platform programming by simply using macros and defining symbols that will do the compilation for each platform.
I'll sticky with FASM by now and forget HLL's for a while... Razz



dont forget to share those macros Wink

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 05 Feb 2006, 19:31
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.