This example program connects to a TCP/IP server at an address you specify. It sends the server the appropriate greeting followed by a carriage return. It then starts listening on the read side of the socket, printing whatever the other side says, until a newline is returned or the server shuts down the connection, whichever happens first.
This program must connect to a server. The most entertaining choice would be to use a greeting server, as described in Chapter 17. You can find a greeting server at net.roguewave.com:3010. If you don't have a greeting server, the next best choice is to use an echo server. Many machines (especially Unix machines) have an echo server configured to run on port 7; use an address of the form hostname:7 to reach it. If you can't connect to a Unix machine, try asking your local system administrator for help finding a server to experiment with.
greet takes the TCP/IP address of the server as the first argument, and your favorite salutation as the second argument. The format is:
greet [<host>:]<port> <greeting>
So, for example, to connect to the greeting server running on port 3010 on net.roguewave.com, you would say:
greet net.roguewave.com:3010 "How's it going, eh?"
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.