socket non blocking of receive

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using the following statement to receive info from a TCPListener socket,

Int32 bytes = s.Receive(RecvBytes, RecvBytes.Length, 0);

It works fine but it blocks. I need the receive to not block. On my
TCPListener I just check intermittently for a connection using pending. This
allow it to be non blocking. Is there a way to do this with Receive?
 
I assume you mean that you're using that code from a Socket. TCPListener
does not have a Receive method. If so, and you are referring to a Socket,
use the Socket.BeginReceive asynchronous method. There are excellent
examples in the MSDN library and framework documentation. Just search for
BeginReceive AND Socket in the MSDN library.

HTH

Dale Preston
MCAD, MCDBA, MCSE
 
Back
Top