CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day14/socket2.py
Views: 729
1
"""
2
套接字 - 基于TCP协议创建时间客户端
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-22
7
"""
8
9
from socket import *
10
11
client = socket(AF_INET, SOCK_STREAM)
12
client.connect(('localhost', 6789))
13
while True:
14
data = client.recv(1024)
15
if not data:
16
break
17
print(data.decode('utf-8'))
18
client.close()
19
20