I am writing an application using a third party python library “Modbus_tk”. I had this running before on a similar Digi device but I am currently getting “Error 12” returned from the socket.accept() method. Can someone please explain what this error message represents. The code below is slightly simplified for readability.
The socket is created with no errors
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout_in_sec)
sock.setblocking(0)
sock.bind((“”,port))
sock.listen(5)
sockets.append(sock)
The main loop checks for incoming connections
inputready, outputready, exceptready = select.select(sockets, [], [], 1.0)
for s in inputready: #handle data on each a socket
try:
if s == sock:
# handle the server socket
LOGGER.debug(“Handle the server socket”)
LOGGER.debug(“… accept”)
client, address = sock.accept()
… more
except Exception, excpt:
LOGGER.warning(“Error while processing data on socket %d: %s”, s.fileno(), excpt)
Error log indicates failure on the accept statement
2016-11-09 14:46:43,609 DEBUG modbus_tcp._do_run Thread-1 Handle the server socket
2016-11-09 14:46:43,619 DEBUG modbus_tcp._do_run Thread-1 … accept
2016-11-09 14:46:43,619 WARNING modbus_tcp._do_run Thread-1 Error while processing data on socket 5: [Errno 12] ERROR