A solution to the error of asynchronous socket error 10053 in C + + Builder

When programming communications using TClientSocket and TServerSocket in C++Builder, clients that use TClientSocket use TClientSocket-> The server using the TServerSocket side will sometimes report the error “” Asynchronous Socket Error 10053″ when the close disconnects and exits the program. Reference to the error instruction: Software caused Connection abort. This is a tricky one because you still can’t be sure where the problem is.
In fact, this error is largely the result of the TClientSocket dropping to Free without a client/server disconnect. There are two solutions here.
A: In the calling TClientSocket TClientSocket before the Close of the call. The Socket. The Close connection is broken, but it also has another problem, there is also did not receive complete data, the server at this time will still be submitted to the Asynchronous Socket error 10053 error, So the call TClientSocket. Socket. Can call again before the Close TClientSocket. Socket. ReceiveText will server sends the data to receive completely
Add the following code to the OnClientError event on the server:

if(ErrorCode==10053)
   Socket->Close;
ErrorCode= 0;

Disconnect the connection and set the ErrorCode to 0. If you don’t, the error code is still 10053 even though the connection is disconnected, you’ll still pop up to report Asynchronous Socket Error 10053.
Original: https://blog.csdn.net/shuiyuanfengxing/article/details/8504139

Read More: