I'm trying to create my own subclass of socket.socket that will be able to handle custom messages. So far my code looks like this:
self._sockets.append(s)
logging.debug("Waiting for incoming connections on port %d" % (port))
while not self.shutdown:
inputready,outputready,exceptready = select(self._sockets,[],[])
print "Select returned"
for i in inputready:
if s == i:
# handle the server socket
client, address = s.accept()
self._sockets.append(client)
print "%r , %r" % (client, address)
else:
# handle all other sockets
s.handleMessage()
so as you can see I'm either acceptin new connections or if it returned from another socket it'll call handleMessage on that socket. Now the problem is that off course socket.accept() will return a socket.socket and not my subclass which implements the handleMessage function.
What would be the easiest way to get my custom class instead of the default socket.socket?