-
Using the TcpClient tcpClient = new();
tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, 5);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, 5);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveRetryCount, 5);
await tcpClient.ConnectAsync("1.1.1.1", 12345);
//... or TcpClient tcpClient = new();
await tcpClient.ConnectAsync("1.1.1.1", 12345);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, 5);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, 5);
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveRetryCount, 5);
//... |
Beta Was this translation helpful? Give feedback.
Answered by
MihaZupan
Mar 15, 2023
Replies: 1 comment
-
As far as I know, it should be safe to set all options before connecting. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Symbai
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As far as I know, it should be safe to set all options before connecting.