When you call closesocket, it notifies the FD_CLOSE event? Or is that only when the server wants to close the socket?

I have a problem you see. The server I guess closes the connection on a paritcular socket. Then the client is suppose to call closesocket to close a connection on that very same socket. And when the server replies to the closing of the socket, another socket is suppose to send some data to the server.

From my sniffer:

11112 -> 2752 <-- ? server closing socket
2752 -> 11112
2752 -> 11112 <-- ? client closing socket
11112 -> 2752
2751 -> 11111
2751 -> 11111 <-- after close, send data on another socket

I can post source of what I have of my program, if anyone can help.
Posted on 2003-05-15 03:35:52 by xkardisx
i used a cheap and probably unreliable method of;



.elseif ax==FD_CLOSE
.if edx==[hSocket2]
invoke closesocket,[hSocket2]
invoke Sleep,50
invoke send,[hSocket1],addr Login3,56,0
.endif
.endif


anyone got a better idea?
Posted on 2003-05-15 03:56:39 by xkardisx
o btw got it to finally log in the damn thing!! hurruza, first step is the hardest ;x
Posted on 2003-05-15 03:56:57 by xkardisx
yes, keep a state variable...

the cheapskate that i am, i often use the variable which i stored the socket handle in as a flag , so when you kill the socket, set the handle to zero, and before you ever use the handle, check if its zero or not !!!
Posted on 2003-05-15 23:37:49 by Homer
Originally posted by xkardisx


.elseif ax==FD_CLOSE
.if edx==[hSocket2]
invoke closesocket,[hSocket2]
invoke Sleep,50
invoke send,[hSocket1],addr Login3,56,0
.endif
.endif


Two remarks:
1) The sleep is unnecessary, by default, the socket shutdown happens in the background anyway and the closure of the handle is done before it returns (closesocket implicitly shuts the socket down).
2) If hSocket1 is in non-blocking mode as well, and the code above is what you actually use, you really need some error checking after the send. It's possible (and even likely) that it will fail (WSAEWOULDBLOCK) or only send a piece of the buffer.

Thomas
Posted on 2003-05-16 01:17:50 by Thomas