server端:

#!/usr/bin/env python

#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

posted on 2016-06-03 09:21  lihanbing  阅读(169)  评论(0编辑  收藏  举报