int main(int argc,char* argv[]){
    int fd;
    if(argc!=3){
        fprintf(stderr,"./timeclnt2 hostname portnum");
        exit(1);
    }
    char* hostname=argv[1];
    int portnum=atoi(argv[2]);
    fd=connect_to_server(hostname,portnum);
    if(fd==-1) exit(1);

    talk_with_server(fd);
    close(fd);
}
Exemple #2
0
int main(int argc, char *argv[]) {
	char host[HOSTLEN];
	gethostname(host, HOSTLEN);
	
	int fd = connect_to_server(host, 12345);
	if( fd < 0 ) {
		printf("ERR: onnect_to_server ret[%d], failed to connect [%s:%d]\n",
				fd, host, 12345);
		return -1;
	}

	talk_with_server(fd);
	close(fd);
	return 0;
}
int main(int ac, char *av[])
{

     if (ac != 2) {
          oops("Usage: ./timecli <IPaddress>");
     }
     int sock_id;       /* line id, file desc     */
     sock_id = connect_to_server(av[1], PORTNUM);
     if (sock_id == -1) {
          oops("connect");
     }
     talk_with_server(sock_id);
     close(sock_id);
     
}
Exemple #4
0
main(int ac, char *av[])
{
	int    fd;			    /* the connected socket	*/
	char   *hostname;

	if ( ac != 3 ){
		fprintf(stderr,"usage: %s hostname portnum\n", av[0] );
		exit(1);
	}
	hostname = av[1];

	/*
	 * make the connection
	 */
	fd = connect_to_server( hostname, atoi(av[2]) );
	if ( fd == -1 ) oops( "connecting to server" );
	talk_with_server( fd );
	close(fd);
}