使用socket类的connect方法
#!/usr/bin/env python
# Basic Connection Example - Chapter 2 - connect.py
import socket
print "Creating socket...",
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "done."
print "Connecting to remote host...",
s.connect(("www.google.com", 80))
print "done."
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/djcsch2001/archive/2008/09/17/2944105.aspx