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).
使用connect()的调用的时候,程序可以解决把主机名转换成IP地址的问题,若主机名不对会产生socket.gaierror,若连接远程主机有问题,会产生socket.error。

售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款