Hi All,
I am running iocLogServer on the win32-x86 platform (base 3.14.12, VS 2010 Express).
If the connection to the log server is inactive for more than 90 second (more precisely, if there are no messages logged) the following error is reported by the IOC (IOC log client):
epics> log client: lost contact with log server at "127.0.0.1:7111" because "An existing connection was forcibly closed by the remote host. "
I was digging a bit in to the iocLogServer.c source code and it seems to me the following statement causes the problem:
494 status = shutdown(pclient->insock, SHUT_WR);
It seems to me that shutting down one half of the connection can also close the opposite half. On the socket level the below two short python programs can be used to reproduce the behavior.
What is the reason for using half-duplex connection only? To my experience the shutdown function is used to close the connection gracefully.
Regards,
Janez
Server side:
import socket
HOST = ''
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
conn.shutdown(socket.SHUT_WR)
while 1:
data = "">
if not data: break
print '"{}"'.format(data)
conn.close()
Client side:
import socket
import time
HOST = 'localhost'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('This should succeed')
time.sleep(100)
s.send('This shuld fail')