#!/usr/bin/python
import socket
# 初始信息
host = 'www.google.com'
port = 80
# 解析域名获取IP
ip = socket.gethostbyname(host)
print('Ip address of ' + host + ' is ' + ip)
# 通过IP连接主机
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, port))
print('Socket Connected to ' + host + ' on ip ' + ip)