Created
April 20, 2015 20:07
-
-
Save nickedes/6c8efacc9b94e0d43600 to your computer and use it in GitHub Desktop.
socket
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 # This is client.py file | |
import socket # Import socket module | |
s = socket.socket() # Create a socket object | |
host = socket.gethostname() # Get local machine name | |
port = 12345 # Reserve a port for your service. | |
s.connect((host, port)) | |
print s.recv(1024) |
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 # This is server.py file | |
import socket # Import socket module | |
s = socket.socket() # Create a socket object | |
host = socket.gethostname() # Get local machine name | |
port = 12345 # Reserve a port for your service. | |
s.bind((host, port)) # Bind to the port | |
s.listen(5) # Now wait for client connection. | |
while True: | |
c, addr = s.accept() # Establish connection with client. | |
print 'Got connection from', addr | |
msg = raw_input("enter plaintext:") | |
c.send(msg) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment