socket non blocking of receive

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?
 
D

Dale Preston

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top