Jan-17-2019, 06:25 PM
My reverse engineering of torchat has led me to a question which I am unable to answer. When I look at the torchat source code, there is a file named tc_client.py, which contains the class “Listener“.
class Listener(threading.Thread):
def __init__(self, buddy_list, socket=None):
threading.Thread.__init__(self)
self.buddy_list = buddy_list
self.conns = []
self.socket = socket
self.start()
self.startTimer()
def run(self):
self.running = True
if not self.socket:
interface = config.get("client", "listen_interface")
port = config.getint("client", "listen_port")
self.socket = tryBindPort(interface, port)
self.socket.listen(5)
while self.running:
try:
conn, address = self.socket.accept()
self.conns.append(InConnection(conn, self.buddy_list))
print "(2) new incoming connection"
print "(2) have now %i incoming connections" % len(self.conns)
except:
print "socket listener error!"
tb()
self.running = False
. . .On line 19 of the code above, there is a socket on which the accept-method is called. As far as I know, the accept method can only be called on a server socket (I come from the JAVA world, where there exists a difference between a Socket and a ServerSocket object). Is the mentioned socket a server socket?
