Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5f2714

Browse files
committed
listen(0) -> listen(1) for Solaris 2
1 parent 749908b commit b5f2714

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Demo/sockets/throughput.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def server():
4545
port = MY_PORT
4646
s = socket(AF_INET, SOCK_STREAM)
4747
s.bind('', port)
48-
s.listen(0)
48+
s.listen(1)
4949
print 'Server ready...'
5050
while 1:
5151
conn, (host, remoteport) = s.accept()
@@ -69,24 +69,24 @@ def client():
6969
else:
7070
port = MY_PORT
7171
testdata = 'x' * (BUFSIZE-1) + '\n'
72-
t1 = time.millitimer()
72+
t1 = time.time()
7373
s = socket(AF_INET, SOCK_STREAM)
74-
t2 = time.millitimer()
74+
t2 = time.time()
7575
s.connect(host, port)
76-
t3 = time.millitimer()
76+
t3 = time.time()
7777
i = 0
7878
while i < count:
7979
i = i+1
8080
s.send(testdata)
8181
s.shutdown(1) # Send EOF
82-
t4 = time.millitimer()
82+
t4 = time.time()
8383
data = s.recv(BUFSIZE)
84-
t5 = time.millitimer()
84+
t5 = time.time()
8585
print data
8686
print 'Raw timers:', t1, t2, t3, t4, t5
8787
print 'Intervals:', t2-t1, t3-t2, t4-t3, t5-t4
8888
print 'Total:', t5-t1
89-
print 'Throughput:', int(float(BUFSIZE*count) / float(t5-t1)),
89+
print 'Throughput:', round((BUFSIZE*count*0.001) / (t5-t1), 3),
9090
print 'K/sec.'
9191

9292

0 commit comments

Comments
 (0)