Created
November 20, 2015 10:42
-
-
Save amir-rahnama/a39290c99a1cb2d6bbad to your computer and use it in GitHub Desktop.
A simple Python Socket Server
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
import socket | |
import random | |
HOST = '127.0.0.1' | |
PORT = 50007 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((HOST, PORT)) | |
s.listen(1) | |
conn, addr = s.accept() | |
print 'Connected by', addr | |
# Make sure you add the '\n' at the end of the stream | |
while 1: | |
data = 'some_string' + '\n' | |
conn.send(data) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment