diff options
author | Chris Liechti <cliechti@gmx.net> | 2016-12-09 20:59:48 +0100 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2016-12-09 20:59:48 +0100 |
commit | c73980721a560b7ca8a5ec4a9d10b6928d2c6487 (patch) | |
tree | 5763f46517bd1ed8abda9ba1009aba1a81fd8126 /examples | |
parent | d8af918473df1d0c0b0867aadd1c731531091ffa (diff) | |
download | pyserial-git-c73980721a560b7ca8a5ec4a9d10b6928d2c6487.tar.gz |
fix: some socket constants not available on Windows
Diffstat (limited to 'examples')
-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 |