Skip to content

Instantly share code, notes, and snippets.

@icarocamelo
Last active September 9, 2015 19:13
Show Gist options
  • Save icarocamelo/54e0f60b6d457031a8e6 to your computer and use it in GitHub Desktop.
Save icarocamelo/54e0f60b6d457031a8e6 to your computer and use it in GitHub Desktop.
simple socket server
#!/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