Exemple #1
0
def echo_client():
    socket=Sock(N, N.net[1])
    s1=socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)
    r=randint(0, 256)
    print "t:", xtime.time(), ("sending data %d to "+ip)%(r)
    s1.sendto('hey '+str(r), (ip, 51423))
    message, address = s1.recvfrom(8192)
    print "t:", xtime.time(), "got reply from %s: %s"%(address, message)
Exemple #2
0
def echo_client():
    socket = Sock(N, N.net[1])
    s1 = socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)
    r = randint(0, 256)
    print "t:", xtime.time(), ("sending data %d to " + ip) % (r)
    s1.sendto('hey ' + str(r), (ip, 51423))
    message, address = s1.recvfrom(8192)
    print "t:", xtime.time(), "got reply from %s: %s" % (address, message)
Exemple #3
0
def tcp_echo_srv():
    """Standard tcp echo server example"""
    host = ''
    port = 51423
    socket=Sock(N, N.net[0])
    s0=socket.socket(AF_INET, SOCK_STREAM)
    s0.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    s0.bind((host, port))
    s0.listen(1)
    while 1: tcp_handler(*s0.accept())
Exemple #4
0
def echo_client_II():
    socket = Sock(N, N.net[1])
    s1 = socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)

    r = randint(0, 256)
    print "t:", xtime.time(), ("II sending data %d to " + ip) % (r)
    s1.connect((ip, 51423))
    s1.send('hey ' + str(r))
    message = s1.recv(8192)
    print "t:", xtime.time(), "got reply from %s: %s" % (ip, message)
Exemple #5
0
def tcp_echo_srv():
    """Standard tcp echo server example"""
    host = ''
    port = 51423
    socket = Sock(N, N.net[0])
    s0 = socket.socket(AF_INET, SOCK_STREAM)
    s0.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    s0.bind((host, port))
    s0.listen(1)
    while 1:
        tcp_handler(*s0.accept())
Exemple #6
0
def echo_client_II():
    socket=Sock(N, N.net[1])
    s1=socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)

    r=randint(0, 256)
    print "t:", xtime.time(), ("II sending data %d to "+ip)%(r)
    s1.connect((ip, 51423))
    s1.send('hey '+str(r))
    message = s1.recv(8192)
    print "t:", xtime.time(), "got reply from %s: %s"%(ip, message)
Exemple #7
0
def tcp_echo_client():
    socket = Sock(N, N.net[1])
    s1 = socket.socket(AF_INET, SOCK_STREAM)
    ip = ip_to_str(0)
    print "t:", xtime.time(), "waiting"
    xtime.swait(70)
    print "t:", xtime.time(), "connecting to " + ip
    s1.connect((ip, 51423))

    r = randint(0, 256)
    s1.send('Hallo, ' + str(r))
    s1.send('How are you?')
    message = s1.recv(8192)
    print "t:", xtime.time(), "tcp server replied:", message
Exemple #8
0
def tcp_echo_client():
    socket=Sock(N, N.net[1])
    s1=socket.socket(AF_INET, SOCK_STREAM)
    ip = ip_to_str(0)
    print "t:", xtime.time(), "waiting"
    xtime.swait(70)
    print "t:", xtime.time(), "connecting to "+ip
    s1.connect((ip, 51423))

    r=randint(0, 256)
    s1.send('Hallo, '+str(r))
    s1.send('How are you?')
    message = s1.recv(8192)
    print "t:", xtime.time(), "tcp server replied:", message
Exemple #9
0
def echo_srv():
    """Standard echo server example"""
    host = ''
    port = 51423
    socket=Sock(N, N.net[0])
    s0=socket.socket(AF_INET, SOCK_DGRAM)
    s0.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    s0.bind((host, port))
    while 1:
            try:
                message, address = s0.recvfrom(8192)
                print "t:", xtime.time(), "Got data from %s: %s"%(address, message)
                s0.sendto('yo there ('+message+')', address)
            except:
                traceback.print_exc()
Exemple #10
0
def echo_srv():
    """Standard echo server example"""
    host = ''
    port = 51423
    socket = Sock(N, N.net[0])
    s0 = socket.socket(AF_INET, SOCK_DGRAM)
    s0.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    s0.bind((host, port))
    while 1:
        try:
            message, address = s0.recvfrom(8192)
            print "t:", xtime.time(), "Got data from %s: %s" % (address,
                                                                message)
            s0.sendto('yo there (' + message + ')', address)
        except:
            traceback.print_exc()