We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52384bf commit 8234fa2Copy full SHA for 8234fa2
client.py
@@ -0,0 +1,10 @@
1
+import socket
2
+
3
+HOST = '127.0.0.1'
4
+PORT = 65432
5
6
+with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
7
+ s.connect((HOST, PORT))
8
+ s.sendall(b'Hello, world')
9
+ data = s.recv(1024)
10
+print('Received', repr(data))
server.py
@@ -0,0 +1,16 @@
+ s.bind((HOST, PORT))
+ s.listen()
+ conn, addr = s.accept()
+ with conn:
11
+ print('Connected by', addr)
12
+ while True:
13
+ data = conn.recv(1024)
14
+ if not data:
15
+ break
16
+ conn.sendall(data)
socket python.zip
-883 Bytes
0 commit comments