I have a socket that I use and then closed it. I f I tried to re use it, I get the following error:
File "myCode.py", line 83,
votingSocket.bind((TCP_IP, TCP_VOTING_PORT))
File "...\Anaconda3\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
File "..\Anaconda3\lib\socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
Here is my code:
votingSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def VotingSessionOnOff():
global votingSocket
if (on)
if votingSocket is None:
votingSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
votingSocket.bind((TCP_IP, TCP_VOTING_PORT))
votingSocket.listen(NUMBER_OF_CLIENTS)
print 'Server opened voting socket!'
else:
votingSocket.close()
When I call the VotingSessionOnOff()
the first time it runs just good, calling it a further time gives the previous error.