# -*- coding: cp936 -*-
"""
根据协议名称获取相应的端口号
http:超文本传输协议
gopher:网际Gopher协议
pop3:适用于C/S结构的脱机模型的电子邮件协议,目前版本3,
ftp:文件传输协议
smtp:简单邮件传输协
telnet:远程登录
"""
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
port = socket.getservbyname("http","tcp")
print "http:",port
port = socket.getservbyname("gopher")
print "gopher:",port
port = socket.getservbyname("ftp")
print "ftp:",port
port = socket.getservbyname("telnet")
print "telnet:",port
port = socket.getservbyname("smtp")
print "smtp:",port
port = socket.getservbyname("pop3")
print "pop3:",port
|