__MagicPower
Do one thing and do it best!

导航

 
#!/usr/bin/env python

import socket

def find_service_name():
	protocolname = 'tcp'
	for port in [80,25]:
		print "Port:%s => service name: %s" %(port,socket.getservbyport(port,protocolname))
	print "Port:%s => service.name:%s"%(53,socket.getservbyport(53,'udp'))

if __name__ == '__main__':
	find_service_name()
	

TEST:

Port:80 => service name: http
Port:25 => service name: smtp
Port:53 => service.name:domain
[Finished in 0.1s]

posted on 2015-12-21 15:30  __MagicPower  阅读(121)  评论(0编辑  收藏  举报