/* Generic TCP client that reads from standard input and forwards to a TCP socket. Also sends to stdout anything received from the socket. This client is IPv6 ready. If the server specified on the command line is an IPv6 address, then IPv6 is used - getaddrinfo takes care of the details! command line parameters identify the TCP server. Uses many functions defined in common.c */ #include /* standard C i/o facilities */ #include /* needed for atoi() */ #include /* Unix System Calls */ #include /* system data type definitions */ #include /* socket specific definitions */ #include /* INET constants and stuff */ #include /* IP address conversion stuff */ #include /* Name lookups (gethostbyname) */ #include #include "common.h" /* =============================================================== The following must passed in on the command line: name or address of the server (argv[1]) port number or service name of the server (argv[2]) getaddrinfo is given both values, and it can handle hostnames, dotted-decimal IPv4 addresses and IPv6 addresses (colon seperated HEX digits). */ int main( int argc, char **argv ) { int sk; /* first - check to make sure there are 2 command line parameters (argc=3 since the program name is argv[0]) */ if (argc!=3) { printf("Usage: client \n"); exit(0); } sk = tcp_connect(argv[1],argv[2]); printf("Connected!\n"); /* print information about the server (uses getnameinfo) */ printremoteinfo(sk); /* Go handle the connection */ tcp_talk(sk); close(sk); return(0); }