-
-
Save teocci/fef629c22bd0da80be7ac552005d0276 to your computer and use it in GitHub Desktop.
a simple tcp server (python code)
This file contains hidden or 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/python | |
# a simple tcp server | |
import socket,os | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.bind(('127.0.0.1', 12345)) | |
sock.listen(5) | |
while True: | |
connection,address = sock.accept() | |
buf = connection.recv(1024) | |
print buf | |
connection.send(buf) | |
connection.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment