python_day8 socket 网络编程 基本篇

服务端:

server=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind(('127.0.0.1',80))
server.listen(5)
conn,address=server.accept()
data=conn.recv(1024)
print(data)
conn.send(data.upper())
conn.close()
server.close()



客户端
import socket
client=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
client.connect(('127.0.0.1',80))
client.send('aaa'.encode('utf-8'))
data=client.recv(1024)
print(data)
client.close()
posted @ 2017-06-20 15:36  昂达达  阅读(167)  评论(0编辑  收藏  举报