I started a simple server that connects to a client, it worked a month ago but now it doesn't.
(我启动了一个连接到客户端的简单服务器,该服务器一个月前就工作了,但现在却没有。)
main
(主要)
def main():
(client_socket, client_address) = start_server(('0.0.0.0', 8200))
print("online")
menu = """
enter the mode wanted out of:
write,
random,
cal,
file,
close to terminate connection"""
menu = menu.encode()
main_menu(client_socket, menu)
client_socket.close()
server_socket.close()
if __name__ == '__main__':
main()
start_server function
(start_server函数)
def start_server(addr):
global server_socket
server_socket = socket.socket()
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind(addr)
server_socket.listen(1)
(client_socket, client_address) = server_socket.accept()
return client_socket, client_address
The server doesnt run the server_socket.accept()
and i get this error for the client :
(服务器没有运行server_socket.accept()
,我为客户端收到此错误:)
OSError: [WinError 10049] The requested address is not valid in its context
(OSError:[WinError 10049]请求的地址在其上下文中无效)
client socket
(客户端套接字)
my_socket = socket.socket() # creates the socket
my_socket.connect(('0.0.0.0', 8200)) # connects to the server
choose_mode(my_socket) # main menu
why does it not accept the client?
(为什么不接受客户?)
ask by LeoSegol translate from so