Created
April 3, 2015 09:24
-
-
Save masasin/9a72f39c27372ef433bb to your computer and use it in GitHub Desktop.
Client code to test yozakura's 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 pickle | |
import socket | |
import time | |
# Create a socket (SOCK_STREAM means a TCP socket) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
try: | |
# Connect to server and send data | |
sock.connect(("localhost", 9999)) | |
while True: | |
sock.sendall("speeds") # If it doesn't work, add "\n" too! | |
# Receive data from the server | |
received = sock.recv(1024) | |
speed = pickle.loads(received) | |
print "Received: {}".format(speed) | |
time.sleep(1) | |
finally: | |
sock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment