Requirements: Two unix machines, Java 1.3, (I think). There's a slight bug that keeps this code from working with Windows. It's related to the input method I use (reading characters instead of reading lines).
This code is derived from the KnockKnock tutorial found on the Java Web sites.
Concepts involved
Sockets
Threads
I/O
Compile with:
javac PeerClient.java ; javac PeerServerThread.java ; javac PeerServer.java ; javac Peer.java ; javac ITypeThread.java Run on Babbage, and on the Georgia Tech machines. Haven't tested on Windows.
To connect to a peer, e.g., the IIT CS machine, type:
:babbage2.cs.iit.edu
The colon identifies this as a connection command, and the rest of the string is the machine name. This code automatically connects to port 4444. (The number of death, to some people).
Code:
PeerClient.java
PeerServerThread.java
PeerServer.java
Peer.java
ITypeThread.java
Compiled Java is also available in this directory. To get it, just change the URL for the files above by substituting the .java suffix for the files above with the .class suffix.