|
50精币
import socket
CLIENT_KEY = '123456'
HOST = '127.0.0.1'
PORT = 12000
def client():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
# 发送注册码
s.sendall(CLIENT_KEY.encode('utf-8'))
# 接收服务端的响应
response = s.recv(1024)
if response.decode('utf-8') == "Welcome !":
while True:
try:
message = s.recv(1024)
if not message:
break
print('收到消息:', message.decode('utf-8'))
except Exception as e:
print('连接中断:', e)
break
else:
print('注册失败')
if __name__ == '__main__':
client()
请问这几行socket的python代码怎么转为e语言代码,可以提供一个简单案例吗? 不太懂?E语言的socket怎么用。
|
评分
-
查看全部评分
|