/// <summary> /// Helper method to set a socket's timeout value /// </summary> /// <param name="sock"> /// socket to set timeout for /// </param> /// <param name="timeout"> /// timeout value to set /// </param> internal void SetSocketTimeout(BaseSocket sock, int timeout) { if (timeout > 0) { sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, timeout); } }
internal void SetSocketTimeout(BaseSocket sock, int timeout) { if (timeout > 0) { try { sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, timeout); } catch (SocketException exception) { this.log.Warn("Failed to set socket timeout: " + exception.Message); } } }