Last active
September 9, 2015 19:14
-
-
Save icarocamelo/b3b083e8852d2cb8d231 to your computer and use it in GitHub Desktop.
simple socket client
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
#client example | |
import socket | |
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print 'Connecting...' | |
client_socket.connect(('127.0.0.1', 8887)) | |
print 'Connected' | |
while 1: | |
data = client_socket.recv(512) | |
if ( data == 'q' or data == 'Q'): | |
client_socket.close() | |
break; | |
else: | |
print "RECEIVED:" , data | |
data = raw_input ( "SEND( TYPE q or Q to Quit):" ) | |
if (data <> 'Q' and data <> 'q'): | |
client_socket.send(data) | |
else: | |
client_socket.send(data) | |
client_socket.close() | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment