Skip to content

Instantly share code, notes, and snippets.

@masasin
Created April 3, 2015 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masasin/9a72f39c27372ef433bb to your computer and use it in GitHub Desktop.
Save masasin/9a72f39c27372ef433bb to your computer and use it in GitHub Desktop.
Client code to test yozakura's server
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