Created
August 8, 2020 07:52
-
-
Save leeyoungseok/32f2ea2aeb0b1afa4e37a1aba1bab030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
IP_ADDR = '0.0.0.0' | |
TCP_PORT = 9999 | |
BUFFER_SIZE = 1024 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((IP_ADDR, TCP_PORT)) | |
s.listen(1) | |
conn, addr = s.accept() | |
print('Connection address:', addr) | |
while 1: | |
data = conn.recv(BUFFER_SIZE) | |
if not data: break | |
print('Data from client:',data.decode('utf-8')) | |
conn.send(data) # echo | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment