eminfedar/async-sockets-cpp

tcpsocket in tcpserver question

Closed this issue · 1 comments

Hi,
I will newClient variable assign outside variable of client , like it as below.
Next, I use command and telnet it, it is connected and fine.
Next, I close client via client variable, the status of IsClosed is 1 that it have closed this connection.
But my telnet is connection, and if I input any key in telnet then it will be closed.

My question is that newClient in the scope of onNewConnection then uses newClient->Close(), and my telnet is disconnected immediately.
I used client->Close() outside of the scope of onNewConnection, and client->IsCloseed showed as closed, but my telnet did not disconnect.

telnet 127.0.0.1 8888

    TCPSocket * client;
    tcpServer.onNewConnection = [&](TCPSocket *newClient) {
         client = newClient
    };

I would suggest checking the errno after calling TCPSocket.Close() to see if there was an error. It may provide some information as to why it's not disconnecting.