diff options
-rwxr-xr-x | examples/tcp_serial_redirect.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/tcp_serial_redirect.py b/examples/tcp_serial_redirect.py index 8440296..53dc0ad 100755 --- a/examples/tcp_serial_redirect.py +++ b/examples/tcp_serial_redirect.py @@ -171,10 +171,13 @@ it waits for the next connect. # connection: After 1 second of idle, start sending TCP keep-alive # packets every 1 second. If 3 consecutive keep-alive packets # fail, assume the client is gone and close the connection. - client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) - client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 1) - client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 1) - client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 3) + try: + client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 1) + client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 1) + client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 3) + client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) + except AttributeError: + pass # XXX not available on windows client_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) try: ser_to_net.socket = client_socket |