Last active
September 9, 2015 19:13
-
-
Save icarocamelo/54e0f60b6d457031a8e6 to your computer and use it in GitHub Desktop.
simple socket server
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 | |
import socket | |
print 'Starting server...' | |
s = socket.socket() | |
host = '127.0.0.1' | |
port = 8887 | |
s.bind((host, port)) | |
print 'Bind' | |
s.listen(5) # Now wait for client connection. | |
while True: | |
c, addr = s.accept() # Establish connection with client. | |
print 'Got connection from', addr | |
c.send('Thank you for connecting') | |
c.close() # Close the connection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment