[comp.protocols.tcp-ip] Shutting down sockets on Apollo/VAX - reply

krm@bcsaic.UUCP (Keith Michaels) (10/04/88)

Re: Hung sockets on Apollo and VAX.

The following program releases socket connections that are left over
after a network application crashes on a VAX running Wollongong TCP/IP.
You have to know the INET: device name assigned to it -- this can sometimes 
be determined by checking the owning PID in SHOW DEV/FULL INET:.
This also seems to clean up the Apollo side at the other end of the link,
but I don't know how to do the equivalent operation from the Apollo.

/* Release unused INET: devices under Wollongong TCP/IP for VAX/VMS */
/* K. Michaels, BCS 27-Sep-1988 */

#include <stdio.h>
#include <ssdef.h>
#include <iodef.h>
#include <descrip.h>
main(ac,av)
int ac;
char *av[];
{
	int i;
	unsigned short iosb[4], chan;
	char idev[16];
	$DESCRIPTOR(idev_dsc,idev);
	if(av[1] == NULL) do {
		printf("inet device name: ");
		if(gets(idev) == 0) exit(SS$_NORMAL);
		} while (strlen(idev) == 0);
	else
		strcpy(idev,av[1]);
	idev_dsc.dsc$w_length = strlen(idev);
	i= sys$assign(&idev_dsc,&chan,0,0);
	if((i & 1) == 0) exit(i);
	i = sys$qiow(0,chan,IO$_SETCHAR,iosb,0,0,&0,0,0,0,0,0);
	if((i & 1) == 0) exit(i);
	if((iosb[0] & 1) == 0) exit(iosb[0]);
	sys$dassgn(chan);
	exit(SS$_NORMAL);
}