DELPHI Newsletter Asynchronous socket error 10053 a workaround

Source: Internet
Author: User
Tags socket error

When using Tclientsocket and Tserversocket in Delphi for programming communication, When a client using Tclientsocket uses Tclientsocket.close to disconnect and exit the program, the server using Tserversocket will sometimes report ' asynchronous socket error 10053 ' This error, read the error description: Software caused connection abort. (Termination of connection due to software reasons). The reason for this is that it's very chicken, because you're still not sure where the problem is.

In fact, this error is very large because there is no client and the server connection is not disconnected directly to the tclientsocket to free, there are two solutions (in fact, is a kind of, but the solution is different, is to disconnect the connection)

One: Call TClientSocket.Socket.Close to disconnect the connection before calling Tclientsocket's close function, but there is another problem, that is, there is still no received full data, and the server will still be reported asynchronous Socket error 10053, so you can call TClientSocket.Socket.Close again before calling TClientSocket.Socket.ReceiveText to receive the data sent by the server fully

Second: Add the following code to the Onclienterror event on the server side:

Case ErrorCode of
10053:socket.close;
End

ErrorCode: = 0;

Disconnect the connection and set ErrorCode to 0, if not set, although the connection is broken, but the error code is still 10053, the window will still pop asynchronous socket error 10053.

DELPHI Newsletter Asynchronous socket error 10053 a workaround

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.