C # Socket The software in your console aborted an established connection an established connection is aborted by the software on your host machine

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.