Please note that the CVS and issue trackers have moved to GitHub. These Trac pages are no longer kept up-to-date.

root/seattle/branches/nacl_repy/seattlelib/tests/ut_lind_net_bind_multiple.py

Revision 5140, 1.0 KB (checked in by justinc, 6 years ago)

removed circular imports and created a new Python testing mechanism called
lind_test_server. This removes the need for wrappers, etc.

Line 
1import lind_test_server
2
3from lind_net_constants import *
4
5SyscallError = lind_test_server.SyscallError
6
7
8sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)
9
10# should work...
11lind_test_server.bind_syscall(sockfd,'127.0.0.1',50102)
12
13
14# let's try to bind another to the same IP /port...
15sockfd2 = lind_test_server.socket_syscall(AF_INET, SOCK_STREAM, 0)
16
17# let's set them to allow port reuse
18lind_test_server.setsockopt_syscall(sockfd, SOL_SOCKET, SO_REUSEPORT, 1)
19lind_test_server.setsockopt_syscall(sockfd2, SOL_SOCKET, SO_REUSEPORT, 1)
20
21# should work...
22lind_test_server.bind_syscall(sockfd2,'127.0.0.1',50102)
23
24# now let's try to listen on both... (should fail on the second)
25
26lind_test_server.listen_syscall(sockfd,10)
27
28try:
29  lind_test_server.listen_syscall(sockfd2,10)
30except SyscallError, e:
31  pass
32else:
33  print 'double listen allowed!!!'
34
35sockfd = lind_test_server.socket_syscall(AF_INET, SOCK_DGRAM, 0)
36# however, UDP should work...
37lind_test_server.bind_syscall(sockfd,'127.0.0.1',50102)
Note: See TracBrowser for help on using the browser.