aboutsummaryrefslogtreecommitdiff
path: root/echo_srv.py
blob: b3855eb1dcfb1ca8bd865568e920e8ac3f6adefb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import socket

HOST = '127.0.0.1' 
PORT = 9095

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((HOST, PORT))
    s.listen()
    conn, addr = s.accept()
    with conn:
        while True:
            data = conn.recv(1024)
            print('recvd: {} bytes'.format(len(data)))
            if len(data) == 0:
                break;
            conn.sendall(data)