/* ** File name: DISCARDD.C ** Product: TCPware for OpenVMS ** Version: V5.6 ** Edit level: 12 ** ** Copyright (c) 2001, 2002 by ** Process Software LLC ** Framingham, Massachusetts ** ** Copyright (c) 1990-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 Discard Server ** ** ** To build on a VAX: ** $ CC /INCLUDE=TCPWARE_INCLUDE DISCARDD.C ** $ LINK DISCARDD,SYS$INPUT/OPTIONS ** SYS$SHARE:TCPWARE_SOCKLIB_SHR/SHARE ** SYS$SHARE:VAXCRTL/SHARE ** ** ** To build on an Alpha: ** $ CC /STANDARD=VAXC/NOMEMBER_ALIGN/ASSUME=NOALIGNED - ** /INCLUDE=TCPWARE_INCLUDE DISCARDD.C ** $ LINK DISCARDD,SYS$INPUT/OPTIONS ** SYS$SHARE:TCPWARE_SOCKLIB_SHR/SHARE */ #include /* ** Add a "#define USE_SOCKET" statement if you want to use sockets ** instead of QIOs. */ #ifdef USE_SOCKET #include "types.h" #include "in.h" #include "inet.h" #include "socket.h" #endif unsigned char buffer[32768]; /* ** Main Program (Discard Server): */ main() { #ifndef USE_SOCKET /* ** Use this code when USE_SOCKET is NOT defined. It uses the TCPware ** for OpenVMS QIO interface. */ int istat, channel; unsigned short iosb[4]; /* ** Get the OpenVMS I/O channel for the TCP connection that ** we are to service (from NETCP - the Master Server). */ istat = tcpware_server(1,&channel); if (istat < 0) return; /* ** Loop receiving data from peer until he closes ** the connection (or an error occurs). ** ** NOTE: For efficiency, we use IO$M_PACKED. */ while (1) { istat = SYS$QIOW (0, channel, IO$_READVBLK | IO$M_PACKED, &iosb, 0, 0, buffer, sizeof(buffer), 0, 0, 0, 0); if (istat & 1) istat = iosb[0]; if (!(istat & 1)) break; } /* ** Close our end of the connection. */ istat = SYS$QIOW (0, channel, IO$_SETMODE | IO$M_CTRL | IO$M_SHUTDOWN, &iosb, 0, 0, 0, 0, 0, 0, 0, 0); /* ** Deassign the OpenVMS I/O channel. */ SYS$DASSGN(channel); #else /* ** Use this code when SOCKET is defined. It uses the TCPware ** for OpenVMS Socket Library. */ int sockp; /* ** Get a socket for the TCP connection that we are ** to service (from NETCP - the Master Server). */ if (tcpware_server(2,&sockp) < 0) return; /* ** Loop receiving data from peer until he closes ** the connection (or an error occurs). */ while (socket_recv(sockp,&buffer,sizeof(buffer),0) > 0); /* ** Close the connection. */ socket_close(sockp); #endif /* ** That's all folks ... */ }