10 int main(int argc,char **argv);
13 static int bytes_received=0;
14 static char title[100];
17 static void usage(s) char *s;{
18 printf("usage: %s host\n",s);
23 static int do_rs( socket_type, protocol, host, service )
25 char *host,*service,*protocol;
28 int sock = sock_open( socket_type, protocol, host, service, 0, AS_CLIENT );
30 if( !sock_cli_send( sock, m, 1 ) ){
31 size=sock_cli_recv(sock,m,sizeof(m));
33 printf("packet size %d\n",size);
41 int main(argc,argv) int argc; char** argv; {
45 if( argc != 2 ) usage(argv[0]);
47 printf("ask for time on %s\n",host);
49 set_cli_recv_timeout( 5000 );
51 if( do_rs( SOCK_DGRAM, "udp", host, "time" ) )
52 printf("time on %s is %u s\n",host,ntohl(*(int *)m));
54 if( do_rs( SOCK_DGRAM, "udp", host, "daytime" ) )
55 printf("daytime on %s is %s\n",host,m);
57 if( do_rs( SOCK_STREAM, "tcp", host, "time" ) )
58 printf("time on %s is %u s\n",host,ntohl(*(int *)m));
60 if( do_rs( SOCK_STREAM, "tcp", host, "daytime" ) )
61 printf("daytime on %s is %s\n",host,m);
63 if( do_rs( SOCK_STREAM, "tcp", host, "ntp" ) )
64 printf("daytime on %s is %s\n",host,m);