There are two programs that cannot establish a direct connection to each other. Write a generic TCP relay server that these two programs can use to send data back and forth. This is common in peer-to-peer networks where one peer cannot talk to another peer, but both peers can talk to a third party (ie the relay server).
- Implement a relay server program that listens for requests over a TCP connection on a given port (for example, port 8080) that will return a (host, port) pair to the requesting client. The relay server should then be able to forward traffic from any program that connects to that (host, port) to the requesting client.
- Any program should be able to take the (host, port) as parameters to talk to the requesting client (via the relay). Assume these programs are not under your control and cannot be modified. An example program might be telnet.
- The requesting client is a program that you can assume is under your control, so any modifications necessary to cont