scokte tcp/ip

import scoket# 服务端

server = socket.socket()

ip_port = ("127.0.0.1",8001)

server.bind(ip_port)

server.lsiten(5)

coon,addr = server.accept()

conn.send("dddd".encode('utf8'))

print(conn.recv(1024).decode('utf8'))

conn.close()

server.close()

import scoket   客户端

client= socket.socket()

ip_port = ('127.0.0.1',8001)

client.connect(ip_port)

client.send('aaa'.encode('utf8'))

client.recv(1024).decode('utf8')

posted @ 2019-01-24 16:29  充电宝宝  阅读(197)  评论(0)    收藏  举报