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
 

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

Socket Send/Receive only works once 1
TCP Send with Response 8
turning sockets off 1
TCP Socket end of data? 2
socket programming 3
TCP Listen port with multiple connections 19
.NET Socket 6
Sockets Question 2

Back
Top