August 29th, 2009, 07:01 AM
Send event with 0 bytes
is it possible to send an event with 0 bytes to a client?
I have a sending thread where messages for the client are collected. The client, when ready for the next incoming data, shall send an "I'm ready event". I know, i could send a message with 1 byte but maybe there are some special functions.
September 10th, 2009, 11:43 AM
Re: Send event with 0 bytes
You don't send events, you send bytes. Thus, a send of 0 bytes will not put any bytes on the wire, and nothing will be received by the recipient.
On the other hand, for connectionless sockets (SOCK_DGRAM), a call to sendto with a length of zero is permissible and will return zero as a valid value. A zero-length transport datagram (i.e., a zero-length message surrounded by IP headers) is sent, and will be received as such by the receiver using recvfrom. See "sendto Function" at http://msdn.microsoft.com/en-us/libr...48(VS.85).aspx
Incidentally, the handshaking you describe (where the client signals "I'm ready" to the server before the server will deliver data) will slow the transfer of data considerably. Try to avoid this type of handshaking, since it results in inefficiencies.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.