3 # SPDX-License-Identifier: GPL-2.0
6 import sys
, os
, os
.path
, getopt
15 try: s
= sock
.recv(rem
)
16 except (socket
.error
) as e
: return b
''
25 except (socket
.error
) as e
: n
= 0
35 serverPort
= SERVER_PORT
38 # create passive socket
39 serverSocket
= socket
.socket(socket
.AF_INET6
, socket
.SOCK_STREAM
)
41 try: serverSocket
.bind(('localhost', 0))
42 except socket
.error
as msg
:
43 print('bind fails: ' + str(msg
))
45 sn
= serverSocket
.getsockname()
48 cmdStr
= ("./tcp_client.py %d &") % (serverPort
)
57 serverSocket
.listen(MAX_PORTS
)
58 readList
= [serverSocket
]
61 readyRead
, readyWrite
, inError
= \
62 select
.select(readList
, [], [], 2)
64 if len(readyRead
) > 0:
66 for sock
in readyRead
:
67 if sock
== serverSocket
:
68 (clientSocket
, address
) = serverSocket
.accept()
69 address
= str(address
[0])
70 readList
.append(clientSocket
)
79 print('Select timeout!')