1st hi all
i want to make 2 prog
1 will be a winsock async server
2 the client also async

but i don't understand the connecting process:
server fully create a socket (with all datas Af_INET,SOCK_STREAM etc...)
set it to assync (WSAAsync....)
it bind it to the port to listen to
and then listen to this socket

create the socket
and connect it

what is the 1st message the server will receive
where do i put the accept call?

once the server call the accept and be fully connected to the client
is there any message sent to the client
how can i proceed into my client prog that the server accepeted the connection on this port
and how to Threat the FD_READ and _FD_WRITE message
is fd_read on the server means that the client used recv
is fd_write on the server means that the client used send
and what is the meanning of this messages on the client

please explain me or give me some peace of code to understand the winsock

and if i have the luck that i get all infos to understand the mechanisms
i'll want to use some algo like MD5 SHA1 to crypt data send/receive to/from server and client

thanks win32asm rocks!
Posted on 2003-05-02 04:05:04 by Thor0Asgard
for starters lets forget the MD5 encryption algo,
and for the winsock part i will suggest going to Thomas website, and download his winsock tut.
I don't know if you have any knowledge of blocking winsocks, but if you don't, you should start from there.
Also, search this forum. You will find a lot of info.
Posted on 2003-05-02 05:42:33 by Ray
Posted on 2003-05-02 07:39:52 by gorshing
Yes you should put the accept call in the code dealing with FD_ACCEPT message server side, and store the new socket in a structure or something

Because on server shutdown you will have to use closesocket on all those new created sockets still active when you want shutdown (this way you will let the clients know server is going down NOW!)

And on the client side you will ask and receive a FD_CONNECT message when the call to connect succeded... only AFTER receiving this message you can assume connection was established ... well if no errors are reported

Please take care as your client code will also recieve an FD_CONNECT even if the connction to server failed but with an error code in HIWORD of lParam

I only treat FD_READ on the server == it means it is time for ME (aka server) to read some data from client using recv function

I personally do not use FD_WRITE neither on server side nor on client side (hmmm maybe i should?)
Posted on 2003-05-02 08:44:48 by BogdanOntanu
u don't watch FD_CLOSE on the server to recognize that a client terminated the session unexpectedly so you can close the now invalid socket handle? curious :tongue:

I don't watch FD_WRITE at all either.


Thats for WSA stuff at least..
Posted on 2003-05-08 00:14:18 by Homer
Surely the listening socket doesnt need to watch FD_READ and FD_CLOSE because it never connects to anything, the accept created socket connects to the client.

Server socket watches (server side): FD_ACCEPT
Accepted socket watches (server side): FD_CLOSE + FD_READ
Client socket watches (client side): FD_CONNECT + FD_CLOSE + FD_READ

for WSAAsyncSelect.
Posted on 2003-05-08 06:06:24 by Lennon