blob: 06c434b0620cfd3ec7c921c7f80596292a657a2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import socket
sock = socket.socket()
server_addr = ('192.168.43.86', 5001)
sock.bind(server_addr)
sock.listen(1)
print("Waiting for connection on " + str(server_addr))
while True:
connection, client_address = sock.accept()
try:
print ('connection from', client_address)
# Receive the data in small chunks and retransmit it
while True:
data = connection.recv(16)
print('received ' ,data)
if not data:
print('no more data from', client_address)
break
finally:
# Clean up the connection
connection.close()
|