http://tieba.baidu.com/p/3223234493
Problem:
When the server receives the client data, it throws an exception:
System.Net.Sockets.SocketException: The software in your console aborted an established connection. An established connection is aborted by the software of your host machine
In System.Net.Sockets.Socket.Receive (byte[] buffer, Int32 size, SocketFlags SocketFlags)
F:\ personal items in the NetWorkingSerivce.ReceiveThread.ReceiveData (Object userstart) Location \networkingserivce\networkingserivce\ ReceiveThread.cs: Line No. 53
Answer:
Play a few days I just made up a LAN within the multi-threaded file transfer program, is WinForm. I've met your problems.
If your server side (file receiver) receives data, shutting down the client (the file sender side) forces the connection to close, and the above error message appears.
It is recommended that you exit the dead loop after receiving the data do not allow the receive function to block, before closing the client (file sending side) is recommended to send a message to the server side (file receiver) "I want to disconnect", and then both sides closed connection close.
When the server receives the client data, it gets the connectionaborted exception.
The server is actively shutting down and connecting to the client when it encounters this exception.
After that, the server will then use this socket to send data out, "Your host software aborted an established connection"
C # Socket The software in your console aborted an established connection an established connection is aborted by the software on your host machine