#

# Python robot client program

# This demonstrates how connecting to the robot server breaks the sonar server.

#


import socket
import string

HOST = '127.0.0.1'           # localhost  

PORT = 5010                  # The port used by the sonar server

sSim = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # python is cool

sSim.connect((HOST, PORT))   # ditto


HOST2 = '127.0.0.1'           # localhost  

PORT2 = 5001                  # The port used by the robot server

sSim2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # python is cool

sSim2.connect((HOST, PORT))   # ditto



counter = 0
velocity = 10.0

while 1:
    # note that whitespace and indentation matters in python

    # feel free to write a java, C++, perl, or befunge client...

    print 'Please input a line to send'     # test commands by hand

    lineToSend = raw_input()                # get input

    lineToSend += "\r\n";
    sSim.send(lineToSend);                  # send it off to the server

    if lineToSend == "q":                   # if we want to quit

        break;
    data = sSim.recv(128);                  # the server always responds!!

    lineReceived = data                     # gratuitous name change

    print 'Received', lineReceived          
    if lineReceived[0] == 'q':              # if server is tired of

        break;                              # getting bullied around...


sSim2.send("q");
sSim.close()
sSim2.close();


syntax highlighted by Code2HTML, v. 0.9.1