/* ** File name: DISCARD.C ** Product: TCPware for OpenVMS ** Version: V5.6 ** Edit level: 12 ** ** Copyright (c) 2001, 2002 by ** Process Software LLC ** Framingham, Massachusetts ** ** Copyright (c) 1991-1999 by ** Process Software Corporation ** Framingham, Massachusetts ** ** This software is furnished under a license for use on a ** single computer system and may be copied only with the ** inclusion of the above copyright notice. This software, or ** any other copies thereof, may not be provided or otherwise ** made available to any other person except for use on such ** system and to one who agrees to these license terms. Title ** to and ownership of the software shall at all times remain ** in Process Software LLC's name. ** ** The information in this document is subject to change ** without notice and should not be construed as a commitment ** by Process Software LLC. Process Software LLC assumes no ** responsibility for any errors that may appear in this document. ** ** ** Abstract: ** TCPware Client-DISCARD (using the INETDRIVER interface) ** ** ** To use on a VAX: ** $ CC /INCLUDE=TCPWARE_INCLUDE DISCARD.C ** $ LINK DISCARD,SYS$INPUT/OPTIONS ** SYS$SHARE:TCPWARE_SOCKLIB_SHR/SHARE ** SYS$SHARE:VAXCRTL/SHARE ** $ DISCARD :== $DISCARD ** ** ** To use on an Alpha: ** $ CC /STANDARD=VAXC/NOMEMBER_ALIGN/ASSUME=NOALIGNED - ** /INCLUDE=TCPWARE_INCLUDE DISCARD.C ** $ LINK DISCARD,SYS$INPUT/OPTIONS ** SYS$SHARE:TCPWARE_SOCKLIB_SHR/SHARE ** $ DISCARD :== $DISCARD */ #include #include #include #include #include #include #include "types.h" #include "in.h" #include "inet.h" #include "netdb.h" #include "socket.h" #include "inetiodef.h" static $DESCRIPTOR (inet_desc,"_INET0:"); char buffer[32768]; check_iosb(istat) unsigned short istat; { if (istat & 1) return; if (istat & 0x8000) { errno = (istat-0x8000)/8; pneterror("%DISCARD-F-SOCKERR"); SYS$EXIT(istat | 0x10000000); } else SYS$EXIT(istat); } main(argc, argv) char *argv[]; { int port, pktcnt, size, i, istat, bytes; char *proto; unsigned short netchan, iosb[4]; struct hostent *he; struct servent *se; struct sockaddr_in name; unsigned long stat_stime[2],stat_etime[2],stat_time[2]; unsigned short stat_ntime[7]; float seconds, kbsec; port = 9; if ((argc < 4) || (argc > 6)) goto usage; if (sscanf(argv[2],"%d",&pktcnt) == 0) goto usage; if (sscanf(argv[3],"%d",&size) == 0) goto usage; if (size > sizeof(buffer)) SYS$EXIT(SS$_BADPARAM); for (i=0;ih_addr,(char *)&name.sin_addr,he->h_length); name.sin_family = he->h_addrtype; } else { name.sin_addr.s_addr = inet_addr(argv[1]); name.sin_family = AF_INET; } proto = "tcp"; if (argc > 5) proto = argv[5]; if (argc > 4) { se = getservbyname(argv[4],proto); if (se == NULL) { sscanf(argv[4],"%d",&port); name.sin_port = htons(port); } else name.sin_port = se->s_port; } else { se = getservbyname("discard",proto); if (se == NULL) name.sin_port = htons(9); else name.sin_port = se->s_port; } if (name.sin_addr.s_addr == 0xFFFFFFFF) SYS$EXIT(SS$_NOSUCHNODE); /* ** Assign a channel to INETDRIVER. */ istat = SYS$ASSIGN(&inet_desc,&netchan,0,0); if (!(istat & 1)) SYS$EXIT(istat); /* ** Create the stream (TCP) or datagram (UDP) socket. */ i = SOCK_STREAM; if (strcasecmp(proto,"UDP") == 0) i = SOCK_DGRAM; istat = SYS$QIOW(0,netchan,IO$_SOCKET,&iosb,0,0, AF_INET,i,0,0,0,0); if (!(istat & 1)) SYS$EXIT(istat); check_iosb(iosb[0]); /* ** Open the connection to the server. */ istat = SYS$QIOW(0,netchan,IO$_CONNECT,&iosb,0,0, &name,sizeof(name),0,0,0,0); if (!(istat & 1)) SYS$EXIT(istat); check_iosb(iosb[0]); /* ** Shutdown the receive side of the socket (we just send data). */ istat = SYS$QIOW(0,netchan,IO$_SHUTDOWN,&iosb,0,0, 0,0,0,0,0,0); if (!(istat & 1)) SYS$EXIT(istat); check_iosb(iosb[0]); printf("Connected to %s,%d. Sending data ...\n", argv[1],ntohs(name.sin_port)); bytes = 0; SYS$GETTIM(stat_stime); /* ** Send the data until we've either sent everything asked or ** some error is reported. */ for (i=0; i