Write a program that optionally accepts an address and a port from the command line. If there is no address and port on the command line, it should create a TCP socket and print the address (i.e. server mode). If there is an address and port, it should connect to it (i.e. client mode). Once the connections are set up, each side should enter a loop of receive, print what it received, then send a message. The message should be “ping” from the client and “pong” from the server. In order to test this, you will need to run the same program twice. I had two command line windows open to run mine. Run first in server mode, then run in client mode using the information printed from the server as your command line arguments.
I need help starting my assignment.
Write a
If there is no address and port on the command line, it should create a TCP socket and print the address (i.e. server mode).
If there is an address and port, it should connect to it (i.e. client mode).
Once the connections are set up, each side should enter a loop of receive, print what it received, then send a message.
The message should be “ping” from the client and “pong” from the server.
In order to test this, you will need to run the same program twice. I had two command line windows open to run mine.
Run first in server mode, then run in client mode using the information printed from the server as your command line arguments.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









