Hello
I am trying to create this small messenger client, but I am having trouble with it.
I would like to know why the connection is closed, I can just send 1 command to the server.
What am I doing wrong?
Posted on 2003-11-16 01:56:50 by Rammstein
.elseif ax == FD_WRITE

.elseif ax == FD_CLOSE
invoke Print, CTXT("Socket Closed.")
.endif


FD_WRITE closes the socket.
Posted on 2003-11-16 10:41:21 by ENF

.elseif ax == FD_WRITE

.elseif ax == FD_CLOSE
invoke Print, CTXT("Socket Closed.")
.endif


FD_WRITE closes the socket.

No it doesn't :confused:.

I think it's closed because you send invalid data:
invoke send, hSocket, addr szBuffer, 256, 0

THis sends 256 bytes to the server, no matter how long the string is. TCP streams are binary streams, they don't care about 0 terminators. Just send exactly the amount of bytes you need to send, nothing more, nothing less.

Also, non-blocking sockets do not guarantee that the all the bytes are sent, or in fact that any of the bytes are sent (it might fail with WSAEWOULDBLOCK). So some error checking is inevitable (as it always should be).

Thomas
Posted on 2003-11-16 12:46:42 by Thomas
aww I though there must be an .endif
Posted on 2003-11-16 13:36:24 by ENF
Thomas you are right, the problem was the string length.
Thank you
Posted on 2003-11-21 01:05:18 by Rammstein
Originally posted by Thomas

Also, non-blocking sockets do not guarantee that the all the bytes are sent, or in fact that any of the bytes are sent (it might fail with WSAEWOULDBLOCK). So some error checking is inevitable (as it always should be).

Thomas


thats why i use multithreaded blocking sockets, i just create a pool of them, and its uber fast.
Posted on 2003-11-24 16:54:48 by Qages