The import socket, threading
S=socket. The socket (socket. AF_INET, socket. SOCK_STREAM) # create server
S.b ind ((30000) "192.168.0.101) # binding native IP
S.l isten (#) to monitor
While True:
C, addr=s.a ccept (#) received from the client connection; This method returns the two parameters, c, and the client scoke corresponding/communication scoket, addr on behalf of the client address
Print (addr)
C.s. end (" hello, this is the service side ". Encode (" utf-8 "))
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The import socket
Client_socket=socket. The socket (socket. AF_INET, socket. SOCK_STREAM) # create a client
Client_socket. Connect ((30000) "192.168.0.101)
Print (client_socket. Recv (2048). The encode (" utf-8 "))
At the same time run in the python shell
CodePudding user response:
FirewallThe machine use 127.0.0.1 localhost, not through the firewall
CodePudding user response: