To get started, download socket_server.py, socket_reader.py, and socket_header.py to the same folder in which you've been working.
Now once more use vi to edit the program you've been running so far (firmata_server.py or usb_sonar_server.py). You'll see two lines beginning with XXX and instructions on how to change your code to serve up data to a client program. Once you've followed those instructions, run your program in one terminal window, then open another and run the socket_reader.py program. If you've done everything right, the sensor data should magically appear in the second terminal as well.
For extra credit, try to run your server one one computer and your client on another.
Note: If you get an error message saying Address already in use, you can wait half a minute and try again, or you can change the value of SOCKPORT in socket_header.py.