How to Abort a Socket in C#

.net, c#, sockets

Solution

I've managed to simulate this situation:

To do a normal graceful disconnection:

you do:

socket.Shutdown(SocketShutdown.Both);
socket.Close();

However, to do an Abort, you do:

socket.Shutdown(SocketShutdown.Send);
socket.Close();

I think the difference is that the client will not receive any ACK packets and thinks the computer reset or something.

Problem

I'm trying to abort a socket connection such that the client at the other end will get a "WSAECONNABORTED (10053) Software caused connection abort." error message when it polls the connection. Close() and Shutdown() will disconnect gracefully. I don't want a graceful disconnection. I want to do an Abort so that the client senses something really went wrong. Thanks, EDIT: I'm coding a Server and I want to abort sockets to connecting clients

Original source

Related problems