Question

According to MSDN Socket.EndSend method can throw a SocketException for a socket using connection-orientated protocol. When ?

I tested a couple of scenarios and none threw a SocketException.

Scenario 1: App calls BeginSend, and while it's sending the data, the app calls BeginDisconnect/Disconnect
Result: Socket doesn't send FIN until all data is sent, and EndSend is successful.

Scenario 2: App calls BeginSend, and while it's sending the data, the socket receives a RST from the remote endpoint.
Result: Socket stops sending data, calls the Callback and EndSend is successful reporting that all bytes have been sent. Don't understand why ?

When does Socket.EndSend method throw a SocketException on a connection-orientated protocol ?

Was it helpful?

Solution

I know that it does raise an error if the connection was severed (as opposed to orderly shut down). You should be able to reproduce this behavior by pulling the network cable. If you can't, please post some code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top