Home/Support/Support Forum/Failure accepting socket on WR44v2 (python)
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Failure accepting socket on WR44v2 (python)

0 votes
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
asked Nov 29, 2016 in 3rd Party Python and API development in other Languages by brownlieig New to the Community (0 points)

Please log in or register to answer this question.

...