Beispiel #1
0
def test():
    global _man
    c_adr = rand_addr()
    s_adr = rand_addr()
    print("Server address: " + hex(s_adr))
    print("Client address: " + hex(c_adr))
    cman = NrlConnectionManager(c_adr)
    sman = NrlConnectionManager(s_adr)
    cman.startUpdateThread()
    sman.startUpdateThread()
    _man = sman
    port = randint(81, 8000)
    print("Using port " + str(port))
    ntl.startNeonetServerThread(handler, port)
    time.sleep(.1)
    cman.addUplink(ntl.TcpClientUplink("localhost", port))
    print("Waiting for routes to resolve...")
    time.sleep(.1)
    cman.sendPacket(s_adr, 1192, b'Hello World!')
    packetBack = sman.getPacket()
    if packetBack == None:
        print("Test failed!")
        return False
    else:
        print("Packet receieved back: " + repr(packetBack))
        return True
Beispiel #2
0
def setup(adr=address,
          tcp_servers=DEFAULT_TCP_SERVERS,
          routing_table={nrl.DEFAULT_AREA_CODE: 0}):
    global address, man, _is_setup
    if _is_setup:
        return "Already set up!"
    address = adr
    man = nrl.NrlConnectionManager(address, routing_table)
    man.startUpdateThread()
    for i in tcp_servers:
        man.addUplink(ntl.TcpClientUplink(i[0], i[1]))
    _is_setup = True