Comp 343/443 program 1: port forwarder When started on host localhost with the command line java forwarder 3333 remotehost 44 then every time a connection is made to localhost:3333, a new connection is made to remotehost:44 and two copier threads are created to copy the data between the two connections (one copier thread for each direction). The net result is that it appears to the user that a connection to localhost:3333 is actually a connection to remotehost:44. No timeouts are needed, though thread creation is necessary. You are to print a line or two for each connection, indicating the original source (host,port) for the incoming connection, and the port used for the outbound forwarded connection. Thread creation is demonstrated in the threaded stalk server file. Here is the general algorithm: 1. wait for a new connection. 2. when it arrives, make the second connection, eg to remotehost:44. 3. At this point you now have two connected sockets, IN (the new inbound connection from step 1) and OUT (the new forwarded connection made in step 2). You must create two new threads, one to copy IN to OUT, and another to copy OUT to IN. I recommend a single general-purpose COPY thread that you can create two instances of. To copy from one socket to another, you first get the associated streams: InputStream is = FROM.getInputStream(); OutputStream os = TO.getOutputStream(); At this point you can read and write, eg int readsize = is.read(buf); os.write(buf, 0, readsize); Each copier thread will run until the connection shuts down. You can identify that via a read that returns -1. To get started, I recommend copying the file tstalks.java, the threaded simplex_talk server, and then renaming appropriately. In particular, the Talker class, with one socket parameter in the ctor, will become the Copier class, with two socket parameters "from" and "to" in the ctor. You will create two instances of Copier, one in each direction, and start up a thread for each. The line_talker() function in tstalks.java becomes a copier() function.