Exemplo n.º 1
0
# I'll listen, accept, and connect...

serversockfd = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)

clientsockfd = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)


# bind to a socket
lind_test_server.bind_syscall(serversockfd,'127.0.0.1',50300)

lind_test_server.listen_syscall(serversockfd,10)

def do_server():
  
  newsocketfd = lind_test_server.accept_syscall(serversockfd)


createthread(do_server)


# wait for the server to run...
sleep(.1)

# should be okay...
lind_test_server.connect_syscall(clientsockfd,'127.0.0.1',50300)
assert(lind_test_server.getpeername_syscall(clientsockfd) == ('127.0.0.1',50300))



Exemplo n.º 2
0
import lind_test_server


from lind_net_constants import *

SyscallError = lind_test_server.SyscallError

# let's do a few basic things with connect.   This will be UDP only for now...

sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_DGRAM, 0)

# should be okay...
lind_test_server.connect_syscall(sockfd,'127.0.0.1',50103)

assert(lind_test_server.getpeername_syscall(sockfd) == ('127.0.0.1', 50103))


# I should be able to retarget it...
lind_test_server.connect_syscall(sockfd,'127.0.0.1',50104)

# now should change...
assert(lind_test_server.getpeername_syscall(sockfd) == ('127.0.0.1', 50104))
Exemplo n.º 3
0
lind_test_server.listen_syscall(serversockfd, 10)


def do_server():
    newsocketfd = lind_test_server.accept_syscall(serversockfd)
    fd = newsocketfd[2]
    lind_test_server.send_syscall(fd, 'jhasdfhjsa', 0)
    lind_test_server.setshutdown_syscall(fd, SHUT_RDWR)

    try:
        # should fail!!!
        lind_test_server.send_syscall(fd, 'jhasdfhjsa', 0)
    except:
        pass
    else:
        print "send after shutdown didn't fail!!!"



createthread(do_server)


# wait for the server to run...
sleep(.1)

# should be okay...

lind_test_server.connect_syscall(clientsockfd, '127.0.0.1', 50431)
assert(lind_test_server.getpeername_syscall(clientsockfd) == \
       ('127.0.0.1', 50431))
Exemplo n.º 4
0
# bind to a socket
lind_test_server.bind_syscall(serversockfd, '127.0.0.1', 50431)
lind_test_server.listen_syscall(serversockfd, 10)


def do_server():
    newsocketfd = lind_test_server.accept_syscall(serversockfd)
    fd = newsocketfd[2]
    lind_test_server.send_syscall(fd, 'jhasdfhjsa', 0)
    lind_test_server.setshutdown_syscall(fd, SHUT_RDWR)

    try:
        # should fail!!!
        lind_test_server.send_syscall(fd, 'jhasdfhjsa', 0)
    except:
        pass
    else:
        print "send after shutdown didn't fail!!!"


createthread(do_server)

# wait for the server to run...
sleep(.1)

# should be okay...

lind_test_server.connect_syscall(clientsockfd, '127.0.0.1', 50431)
assert(lind_test_server.getpeername_syscall(clientsockfd) == \
       ('127.0.0.1', 50431))
import lind_test_server

from lind_net_constants import *

SyscallError = lind_test_server.SyscallError

# let's do a few basic things with connect.   This will be UDP only for now...

sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_DGRAM, 0)

# should be okay...
lind_test_server.connect_syscall(sockfd, '127.0.0.1', 50103)

assert (lind_test_server.getpeername_syscall(sockfd) == ('127.0.0.1', 50103))

# I should be able to retarget it...
lind_test_server.connect_syscall(sockfd, '127.0.0.1', 50104)

# now should change...
assert (lind_test_server.getpeername_syscall(sockfd) == ('127.0.0.1', 50104))