Does Socket.Shutdown() or Socket.Close() block?

P

PAzevedo

Hi there.

I called Socket.Select() on a group of sockets, and got one that was
writable.
On that socket i called Send() and sent a buffer of size smaller then
SendBufferSize that way Send() won't block.
Now right after that Send() i want to get ride of the socket but since
my server model isn't asynchronous i don't want to block.
So what should i do?
If i call Shutdown() and then Close() will either of them block? If
there is a way they won't block, will that way also guarantee the data
sent previously will reach it's destiny?


Thank you for your time.
 
P

Peter Duniho

[...]
If i call Shutdown() and then Close() will either of them block? If
there is a way they won't block, will that way also guarantee the data
sent previously will reach it's destiny?

Neither method will block. But there is no way to guarantee that the data
you passed to the Send method will arrive at the destination.

For what it's worth, you have no such guarantee even if you don't call
Shutdown or Close. The only way for the sender to know for sure what data
arrived at the destination is for that destination to report that explicitly
to the sender.

Pete
 

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

Top