A. Socket
TCP is a connection-based protocol, so you must start the server before you use the client to connect to the server.
UDP is not a connection-oriented protocol, so after starting the server, you do not need to establish a connection with the server in advance, you can accept the message directly
Detailed socket Parameters:
Socket method:
Service-side socket function S.bind () bind (host, port number) to Socket S.listen () Start TCP Listener s.accept () Passive Accept TCP Client connection, (blocked) Wait for connection arrival client socket function S.connect () actively initializes an extended version of the TCP server Connection S.CONNECT_EX () connect () function, returning an error code when an error occurs, rather than throwing an exception to the common-use socket function S.recv () receive T CP Data S.send () sends TCP data S.sendall () sends TCP data S.recvfrom () receives UDP data s.sendto () sends UDP data s.getpeer Name () connects to the remote address of the current socket S.getsockname () The address of the current socket s.getsockopt () returns the parameter of the specified socket s.setsockopt () setting the specified set The parameter S.close () of the socket closes the socket for the lock socket Method S.setblocking () sets the blocking and non-blocking mode of the socket S.settimeout () sets the timeout period for the blocking socket operation S.gettimeout () Gets the timeout time of the blocking socket operation the function of the socket for the file S.fileno () The file descriptor of the socket S.makefile () creates a file associated with the socket
Python socket module