The client and server take turns initiating the MSG protocol sending and receiving strings back and forth. Each program reads in the next string to send to the other from the user. The client and server programs read in the next message string from the user, then send it to the other party using the MSG protocol.
In this example, the server is running on carrot and the clients are running on paprika.
You can use ifconfig to list a machine's IP address, or nslookup to list the IP of another machine:
% ifconfig # look at the eth0 entry % nslookup lime # list lime's IP address
paprika % ./cs87_client 130.58.68.67 tia you are going to connect to the talk server on 130.58.68.67 enter next message at the prompt, enter goodbye to end Connected. $: hello there hi tia your msg: hi server, do you have any licorice? no, not really $: it would be much cooler if you did whatever $: goodbye I'm out of here bye, bye paprika % paprika % ./cs87_client 130.58.68.67 elmo you are going to connect to the talk server on 130.58.68.67 enter next message at the prompt, enter goodbye to end $: hello there hi elmo, what can I do for you? $: well, nothing. I'm just saying hi okay, hi back. $: okay, so long bye $: goodbye I'm out of here bye, bye paprika %
carrot % ./cs87_server Accepted new client socket. New client (tia) passed HELLO check. tia:hello there $: hi tia tia:hi server, do you have any licorice? $: no, not really tia:it would be much cooler if you did $: whatever client QUIT server ending connection Accepted new client socket. New client (elmo) passed HELLO check. elmo:hello there $: hi elmo, what can I do for you? elmo:well, nothing. I'm just saying hi $: okay, hi back. elmo:okay, so long $: bye client QUIT server ending connection