[mess] [python] Naive Echo Server
2021-07-16 10:06
标签:soc nec input print imp str bre line ESS [mess] [python] Naive Echo Server 标签:soc nec input print imp str bre line ESS 原文地址:https://www.cnblogs.com/wander4096/p/9534745.html# server.py
from socket import *
HOST = ‘‘
PORT = 50007
s = socket(AF_INET, SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
(conn, addr) = s.accept()
while True:
data = conn.recv(1024)
if not data:
break
conn.send(data)
conn.close()
# client.py
from socket import *
HOST = ‘‘
PORT = 50007
s = socket(AF_INET, SOCK_STREAM)
s.connect((HOST, PORT))
while True:
line = input()
if not line:
break
s.send(str.encode(line))
data = s.recv(1024)
print(data)
s.close()
文章标题:[mess] [python] Naive Echo Server
文章链接:http://soscw.com/essay/105970.html