socket.gethostname,
ocket.getprotobyname(
protocolname): refer to /etc/protocols
socket.getservbyname(
servicename[,
protocolname]): refer to /etc/services.
- from socket import *
-
-
hostname = gethostname()
-
print hostname
-
try:
-
http_port = getservbyname('http', 'tcp')
-
except socket.error:
-
print "kdkd"
-
-
print http_port
阅读(543) | 评论(0) | 转发(0) |