From 5c03c29b530289179fb449ba757678a7fc0b8ed7 Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Thu, 21 May 2020 06:53:13 +1000 Subject: [PATCH] socket.recv does not work how I though it did --- TWS/twsproxy/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TWS/twsproxy/__init__.py b/TWS/twsproxy/__init__.py index f84e09a..55bbc8b 100644 --- a/TWS/twsproxy/__init__.py +++ b/TWS/twsproxy/__init__.py @@ -206,10 +206,16 @@ class TWSProxy(threading.Thread): if msglength > 0: TWSProxy.reliablesend(dest,buff,msglength) if msglength == 0: - logger.debug('msglength 0, closing {} {}'.format(src,dest)) - dest.shutdown(shuttype) - initshutdown.set() - closed = True + """ + see https://manpages.debian.org/buster/manpages-dev/recv.2.en.html + in particular + Datagram sockets in various domains (e.g., the UNIX and Internet domains) permit zero-length datagrams. When such a datagram is received, the return value is 0. + """ + logger.debug('msglength 0, sending 0 {} {}'.format(src,dest)) + dest.send(buff) + #dest.shutdown(shuttype) + #initshutdown.set() + #closed = True logger.debug('ending sock copy {} {}'.format(src,dest)) dest.shutdown(shuttype) -- GitLab