server端:
#coding:utf-8
import socket
sk = socket.socket()
ip_port = ('127.0.0.1','9999')
sk.bind(ip_port)
sk.listen(5)
conn,address = sk.accept()
conn.send('hello')
conn.close()
client端:
#!/usr/bin/env python
#coding:utf-8
import socket
client = socket.socket()
ip_port = ('127.0.0.1','9999')
client.connect(ip_port)
data = client.recv(1024)
print data