Home > Back-end >  Use of TServerSocket, close the program, the TCP server is not closed
Use of TServerSocket, close the program, the TCP server is not closed

Time:10-12

1. So, I use TServerSocket this control to open TCP server mode,
2. But sometimes shut down when the server is not off, also in LISTENING, this time I'll be there to open the program socket repeat mistake,
3. In my own computer test is not the fault of others computer shut out occasionally,
4. I have been in the FormDestroy () function and destructors are closed, but still not successful,
5. What is the cause of this? Because I exit in the right way? Exit is to call the Close () method,
6. I find TClientSocket also have such problems,

The following is a closed code:

If (ServerSocket1 - & gt; The Active)
{
ServerSocket1 - & gt; Active=false;
ServerSocket1 - & gt; Close ();
}
If (ClientSocket1 - & gt; The Active)
{
ClientSocket1 - & gt; Active=false;
ClientSocket1 - & gt; Close ();
}

CodePudding user response:

Active=false, and the Close, a snake,

The Close method will be the Active set to false, the Open method is to Active set to true,

CodePudding user response:

Is, but I'm afraid it shut down is not successful, both tried, there will be not shut down the BUG,

CodePudding user response:

reference 1st floor ccrun response:
is Active=false, it is Close, a snake,

The Close method will be the Active set to false, the Open method is to Active set to true,


Is, but I'm afraid it shut down is not successful, both tried, there will be not shut down the BUG,

CodePudding user response:

I suggest that in the OnClose event of the Form, first traverse the current connection of the client, one by one off the client connection, and then Close the service side,

CodePudding user response:

reference 4 floor ccrun response:
I suggest in the OnClose event of the Form, traverse the current connection of client first, one by one off the client's connection, and then Close the service side,


Ok,
  • Related