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 HostName
= socket
.gethostname()
40 # create passive socket
41 serverSocket
= socket
.socket(socket
.AF_INET6
, socket
.SOCK_STREAM
)
42 host
= socket
.gethostname()
44 try: serverSocket
.bind((host
, 0))
45 except socket
.error
as msg
:
46 print('bind fails: ' + str(msg
))
48 sn
= serverSocket
.getsockname()
51 cmdStr
= ("./tcp_client.py %d &") % (serverPort
)
60 serverSocket
.listen(MAX_PORTS
)
61 readList
= [serverSocket
]
64 readyRead
, readyWrite
, inError
= \
65 select
.select(readList
, [], [], 2)
67 if len(readyRead
) > 0:
69 for sock
in readyRead
:
70 if sock
== serverSocket
:
71 (clientSocket
, address
) = serverSocket
.accept()
72 address
= str(address
[0])
73 readList
.append(clientSocket
)
82 print('Select timeout!')