Esempio n. 1
0
 def run(self):
     self.init_request()
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.sock.connect((self.destip, self.destport))
     while True:
         try:
             msg = coding.decode(self.sock.recv(4096))
         except:
             self.sock.close()
             return
         self.parsemsg(msg)
Esempio n. 2
0
 def run(self):
     self.init_request()
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.sock.connect((self.destip, self.destport))
     while True:
         try:
             msg = coding.decode(self.sock.recv(4096))
         except:
             self.sock.close()
             return
         self.parsemsg(msg)
Esempio n. 3
0
 def run(self):
     self.conn, addr = self.sock.accept()
     print(addr)
     while True:
         # once the connection is established, recv won't block
         # even if no message is received
         try:
             msg = coding.decode(self.conn.recv(4096))
         except:
             self.sock.close()
             return
         self.parsemsg(msg)
Esempio n. 4
0
 def run(self):
     self.conn, addr = self.sock.accept()
     print(addr)
     while True:
         # once the connection is established, recv won't block
         # even if no message is received
         try:
             msg = coding.decode(self.conn.recv(4096))
         except:
             self.sock.close()
             return
         self.parsemsg(msg)
Esempio n. 5
0
    def run(self):
        print('p2p chat available')
        while True:
            conn, addr = self.sock.accept()
            name = coding.decode(conn.recv(1024))

            # start a TCP peer connection for that client
            tcppeer = Peer()
            conn.send(coding.encode(str(tcppeer.getport())))
            self.tcppeers[name] = tcppeer
            chat_thread = threading.Thread(target=tcppeer.start)
            chat_thread.daemon = True
            chat_thread.start()
            conn.close()

            #switch the active dest to the recently connected one
            self.active_dest = name
Esempio n. 6
0
 def run(self):
     print('p2p chat available')
     while True:
         conn, addr = self.sock.accept()
         name = coding.decode(conn.recv(1024))
         
         # start a TCP peer connection for that client
         tcppeer = Peer()
         conn.send(coding.encode(str(tcppeer.getport())))
         self.tcppeers[name] = tcppeer
         chat_thread = threading.Thread(target=tcppeer.start)
         chat_thread.daemon = True
         chat_thread.start()
         conn.close()
         
         #switch the active dest to the recently connected one
         self.active_dest = name
Esempio n. 7
0
 def init_request(self):
     self.sock.connect((self.destip, self.destport))
     self.sock.send(coding.encode(self.name))
     self.destport = int(coding.decode(self.sock.recv(1024)))
     self.sock.close()
Esempio n. 8
0
 def init_request(self):
     self.sock.connect((self.destip, self.destport))
     self.sock.send(coding.encode(self.name))
     self.destport = int(coding.decode(self.sock.recv(1024)))
     self.sock.close()