Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	char *host, *type = argv[1];
	printf("Type received is: %c\n", *type);
	if(*type == '6') {
		host = "::1";
		printf("Sending IPv6 request \n");
	}
	else if(*type == '4') {
		host = "localhost";
		printf("Sending IPv4 request \n");
	}
	else {
		errexit("Unexpected input for the IP version: %c \n", *type);
	}

	TCPdaytime(host, type);
	exit(0);
}
Exemplo n.º 2
0
/*------------------------------------------------------------------------
 * main - TCP client for DAYTIME service
 *------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
        char    *host = "localhost";    /* host to use if none supplied */
        char    *service = "daytime";   /* default service port         */

        switch (argc) {
        case 1:
                break;
        case 3:
                service = argv[2];
                /* FALL THROUGH */
        case 2:
                host = argv[1];
                break;
        default:
                fprintf(stderr, "usage: TCPdaytime [host [port]]\n");
                exit(1);
        }
        TCPdaytime(host, service);
        exit(0);
}