I have written a server code using the Windows Socket API's. Wherein I have
created the socket and bound it to a particular IP address and port number.
Later I have made the socket in non-blocking mode by using the proper socket
option ( i.e. SO_RCVTIMEO). After which with the use of recv() I am trying to
get into the receive mode. Here as the receive time out is being used the
socket should come out of the block mode after the time out value. But this
is not happening here, instead the socket is always in the blocking mode.
I am facing this kind of an issue only on few of the VISTA systems. Whereas
on few other VISTA systems it is working fine (means we are ableto switch
between block and non-block modes).
But there is no problem on any of the XP systems.
Could you please provide me with information related to this and help in
deriving a proper conclusion.
Thanks in advance,
Rajni
"William Stacey [MVP]" wrote:
"If no data is available for reading, the Receive method will block until
data is available. If you are in non-blocking mode, and there is no data
available in the in the protocol stack buffer, the Receive method will
complete immediately and throw a SocketException . An error occurred when
attempting to access the socket. See Remarks below. You can use the
Available property to determine if data is available for reading. When
Available is non-zero, retry the receive operation.
If you are using a connection-oriented Socket, the Receive method will read
as much data as is available, up to the number of bytes specified by the
size parameter. If the remote host shuts down the Socket connection with the
Shutdown method, and all available data has been received, the Receive
method will complete immediately and return zero bytes."
If there is 1 byte in queue, it will return the 1 byte. However if more, it
will only return upto 4 bytes and leave the rest in the queue for next read.
If you are in non-blocking mode and there is not data, then receive will
throw SocketException . hth
--
William Stacey, MVP
"War Eagle" <Wa******@discu ssions.microsof t.comwrote in message
news:21******** *************** ***********@mic rosoft.com...clientSocket.Re ceive(PreRxBuff er, 0,4, 0);What if the client sends 5 bytes or 5000 bytes?
Does this function block? What happens if the client only sends 3 bytes?