The
1.listen function Converts an active socket into a passive socket backlog to specify the size of the corresponding socket connection queue. The listener socket has 2 queues: (1) The connection queue is not completed, the client SYN is received, a SYN is sent, an ACK is made, and three handshakes are waiting to be completed. This socket is in the SYN_RCVD state. (2) The connection queue has been completed and the TCP three handshake has been completed. These sockets are in the established state. The
3.getsockname and Getpeername functions either return the local protocol address (GETSOCKNAME) associated with a socket, or return the field protocol address (getpeername) associated with a socket. Description: 1) client, do not call bind, after connect, to obtain their own IP, Port 2) client, after the port number 0 call bind, you can obtain their own port 3) server, to connect IP address call bind, need to establish a connection with the client (accept) In order to get their own IP
Basic TCP Socket Programming