/* NAME: tcpClient0 SYNOPSIS: tcpClient0 DESCRIPTION: The program creates a tcp socket in the inet domain, connects to tcpServer0 running at and waiting at port 10345, sends the message "HI" and exits */ #include "def" main(argc, argv ) int argc; char *argv[]; { int sd; struct sockaddr_in server; struct hostent *hp, *gethostbyname(); sd = socket (AF_INET,SOCK_STREAM,0); server.sin_family = AF_INET; hp = gethostbyname(argv[1]); bcopy ( hp->h_addr, &(server.sin_addr.s_addr), hp->h_length); server.sin_port = htons(atoi(argv[2])); connect(sd, (SA *) &server, sizeof(server)); for (;;) { send(sd, "HI", 2, 0 ); printf("sent HI\n"); sleep(2); } }