Summarize the functions commonly used in python network programming
socket.getservbyname(servicename[, protocolname]) –> integer 查询某个协议对应的端口号,需要使用两个参数,servicename对应端口名称,如 http, smtp,等。protocolname对应tcp,udp。
s.getsockname() s.getpeername()
getsockname: Return the address of the local endpoint. For IP sockets, the address info is a pair (hostaddr, port)
getpeername: Return the address of the remote endpoint.For IP sockets, the address info is a pair (hostaddr, port). Related socket.gaierror
Socket.herror related to other address errors