我尝试运行此代码,但是没有用 有人可以帮我吗?
import socket
import sys
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "The socket was created succesfully"
except socket.error as err:
print "The creation of the socket failed due to error %s" %(err)
port = 80
try:
host_ip = socket.gethostbyname('www.adress.com')
except socket.gaierror:
print "An error occured while resolving the host"
sys.exit()
s.connect((host_ip.port))
print "Succesfully connected to adress\
on port == %s" %(host_ip)