jchristn / SuperSimpleTcp

Simple wrapper for TCP client and server in C# with SSL support
MIT License
459 stars 95 forks source link

keepalive is not working on win7 #151

Closed jwj15 closed 2 years ago

jwj15 commented 2 years ago

I use tcpclient


Environment SuperSimpleTcp : v3.0.0 NET6 runtime : v6.0.8 OS : Windows7 Service Pack 1


Enabling the keepalive option causes an error

option --> client.Keepalive.EnableTcpKeepAlives = true; error message --> "keepalives not supported on this platform, disabled"

If data is sent after an error, the following message is output.

disconnection detected
dispose complete

I do a connection check before sending data. but this code passes

if (client == null)
{
    log.Error("client is null");
    GetClient();
}
else if (!client.IsConnected)
{
    log.Error("client is not connected");
    client.Connect();
}

But Windows 10 and 11 work fine.

jchristn commented 2 years ago

Hi @jwj15 this is happening in the catch block of EnableKeepalives (see https://github.com/jchristn/SuperSimpleTcp/blob/52ba8d1aaea486a9599ac71e2aab3de7e8df1041/src/SuperSimpleTcp/SimpleTcpClient.cs#L1069 and https://github.com/jchristn/SuperSimpleTcp/blob/52ba8d1aaea486a9599ac71e2aab3de7e8df1041/src/SuperSimpleTcp/SimpleTcpServer.cs#L1109). If this is happening, it's an issue with the underlying implementation in the operating system with the runtime you've selected. It is, unfortunately, not an issue that is under my control, because it's not an issue in the library.