コード例 #1
0
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!!!"
コード例 #2
0
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!!!"
コード例 #3
0
# write should succeed
assert(lind_test_server.write_syscall(myfd, 'hello there!') == 12)

lind_test_server.close_syscall(myfd)

# Now, re open the file

myfd = lind_test_server.open_syscall('/foo', O_RDWR, S_IRWXA)

lind_test_server.close_syscall(myfd)


# 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_STREAM, 0)


# bind will not be interesting...
assert lind_test_server.bind_syscall(sockfd, '10.0.0.1', 50102) == 0
try:
    lind_test_server.setshutdown_syscall(sockfd, SHUT_RD)
except:
    pass

myfd = lind_test_server.open_syscall('/foo', O_RDWR, S_IRWXA)
lind_test_server.close_syscall(myfd)

myfd = lind_test_server.open_syscall('/foo', O_RDWR, S_IRWXA)

lind_test_server.close_syscall(myfd)