def __init__(self,dispatcher,isClient):
     self.sessions={}
     self.dispatcher=dispatcher
     f = open(constants.nid_filename, "r")
     self.nid = f.readline().strip()
     self.keys = crypto.loadKeyPair( self.nid + "_N_" )
     self.hostSSLport=443
     self.isClient=isClient
Пример #2
0
def tcp_serverthread( dispatcher, ssock ):
    f = open(constants.nid_filename, "r")
    nid = f.readline().strip()
    
    keys = crypto.loadKeyPair( nid + "_N_" )
    # TONY: 
    #address = ( socket.gethostbyname_ex(socket.gethostname())[2][0], 5000 )
    address = ( "0.0.0.0", int(myPubaddr[1]) )#@Ali Random port
    ssock.bind( address ) 
    ssock.listen( 5 )
    logging.info( "TCP server started on {0}...".format( address ) )
    
    while True:
        try:
            csock, caddr = ssock.accept()

            tcp_handler_thread = threading.Thread( target=tcp_recieveItem,
                                      name="tcp_handler_thread for "+str(caddr),
                                      args=( csock, caddr,dispatcher,keys) )
            tcp_handler_thread.daemon = True
            tcp_handler_thread.start()
        except:
            print traceback.print_exc()