#include #include #include #include #include #include #include #include #include #include /* change hostent to comply with BSD 4.3*/ #include #include /* INET symbol definitions */ int sock_1; /* socket */ static char message[] = "ibs\r\n"; static struct sockaddr_in sock2_name; /* Address struct for socket2.*/ struct hostent hostentstruct; /* Storage for hostent data. */ struct hostent *hostentptr; /* Pointer to hostent data. */ static char hostname[32]; /* Name of local host. */ int flag; int retval; /* helpful for debugging */ int shut = FALSE; /* flag to cleanup */ char host_name [ ] = "MVP01"; int port_number= 23; char buff [16384]; int count = 0; void cleanup (int shut,int socket); /*--------------------------------------------------------------------*/ void main (void) { printf("host_name=%s & port_number=%d",host_name,port_number); for(count = 0;;count++) { printf("%d,",count); if ((sock_1 = socket (AF_INET, SOCK_STREAM, 0)) == -1) { perror( "socket"); lib$signal(errno); } if ((hostentptr = gethostbyname (host_name)) == NULL) { perror( "gethostbyname"); cleanup(shut, sock_1); } hostentstruct = *hostentptr; sock2_name.sin_family = hostentstruct.h_addrtype; sock2_name.sin_port = htons(port_number); sock2_name.sin_addr = * ((struct in_addr *) hostentstruct.h_addr); retval = connect(sock_1, (struct sockaddr *) &sock2_name, sizeof (sock2_name)); if (retval) { perror("connect"); cleanup(shut, sock_1); } if ( 0 > send (sock_1,message,sizeof(message)-1,0) ) { perror("send"); cleanup(shut, sock_1); } } } /* end main */ /*-----------------------------------------------------------*/ void cleanup (int shut,int socket) { int retval; /* * Shutdown socket completely -- only if it was connected */ if (shut) { retval = shutdown(socket,2); if (retval == -1) perror ("shutdown"); } /* * Close socket. */ retval = close (socket); if (retval) perror ("close"); printf("\nTotal IO chanels = %d",count); lib$signal(errno); }