From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 24-OCT-1990 06:14:00.97
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: Dedicated LAT-service doesn't break connection on port close.

Received:  by crdgw1.ge.com (5.57/GE 1.76)
	 id AA04075; Wed, 24 Oct 90 05:58:33 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Wed, 24 OCT 90 02:49:08 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA20837; Wed, 24 Oct 90 02:32:12 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 22 Oct 90 08:15:08 GMT
From: cbmvax!xmws!baxter@rutgers.edu
Organization: Xmws Associates, Phoenixville, PA
Subject: Re: Dedicated LAT-service doesn't break connection on port close.
Message-Id: <39.2722724c@xmws>
References: <rcbatg.656349471@rw7.urc.tue.nl>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <rcbatg.656349471@rw7.urc.tue.nl>, rcbatg@rw7.urc.tue.nl (Tonnie Geraets) writes:
> Hello,
> 
> I'm writing a dialin-server, which has to run as a dedicated LAT-service on
> a VMS-system.
> 
> Everything works ok, without any error values returned. The only thing that
> doesn't work: when I close the port, the user isn't disconnected, but the
> program just waits for a cariage return and starts over again.
> 
> Examples of working dedicated LAT-services are also welcome (for example the
> TIME-service described in the manual).
> 
You need to make sure the LAT port itself is setup to log off the user
when you drop the connection... If you set the LAT PORT to modem control 
and set the modem to drop carrier and reset whe DTR is DROPPED, it will
worng correctly... 

Several other things I noticed:  After you open the port you need to
issue a LAT connect request QIO:

    sys$qiow( write_QIO_efn, channel,
             (IO$_TTY_PORT | IO$M_LT_CONNECT), &iosb,
                        0, 0, 0, 0, 0, 0, 0, 0 );
    if ( even( iosb.condition )) do_lat_open_error( iosb );

I also noticed that you have not enabled a control_y ast handler on the 
channel so that you will get hangup notification... (if the NETWORK connection
is broken for some reason... or the LAT is rebooted:

    rs = sys$qiow( write_QIO_efn, channel,
                (IO$_SETMODE | IO$M_CTRLYAST), &iosb,
                0, 0, hangup_ast, 0,  0, 0, 0, 0 );

    if ( even(rs) || even(iosb.condition) ) do_lat_open_error( iosb );

What follows is a LAT programming example from DEC:

(Constants contain within ARE NOT sys$library... at least on vms 5.3-1)


#include descrip
#include iodef

/* #ifndef IO$_TTY_PORT */
/* define the next bunch here, if they don't appear in IODEF */
#define   IO$_TTY_PORT        41
#define   IO$M_LT_MAP_PORT   512
#define   IO$V_LT_MAP_NODNAM   1    /* use IO$V_ not IO$M_ */
#define   IO$V_LT_MAP_PORNAM   2
#define   IO$V_LT_MAP_SRVNAM   3
#define   IO$V_LT_MAP_LNKNAM   4
#define   IO$V_LT_MAP_NETADR   5
/* #endif */

/* set up some useful structures */
struct IOSB {
    short unsigned int     status, unused;
    unsigned int           reserved;
};

struct ITMLST {
    short unsigned int  buffer_length,
                        item_code;
    char                *buffer_address;
    unsigned int        *return_length_address;
};

main(){

    unsigned int status, q = 1;
    short unsigned int lat_io_channel;
    char *srvr_name = "TRMSVR", *port_name = "PORT_2",
         *link_name = "LAT$LINK";  /* it MUST be this name  */
    struct IOSB iosb;
    struct ITMLST itmlst[] = {
                              { strlen( link_name ), IO$V_LT_MAP_LNKNAM,
                                link_name, 0 },
                              { strlen( srvr_name ), IO$V_LT_MAP_NODNAM,
                                srvr_name, 0 },
                              { strlen( port_name ), IO$V_LT_MAP_PORNAM,
                                port_name, 0 },
                              { 0, 0, 0, 0 }
                             };
    static $DESCRIPTOR( lat_device, "_LTA9995:" );

    if( !( ( status = sys$assign( &lat_device, &lat_io_channel,
                                  0, 0 ) ) & 1 ) )
        lib$stop( status );

    if( !( ( status = sys$qiow( 0, lat_io_channel,
                                IO$_TTY_PORT | IO$M_LT_MAP_PORT,
                                &iosb, 0, 0,
                                &itmlst, q,
                                0, 0, 0, 0 ) ) & 1 ) )
        lib$stop( status );
    if( !( iosb.status & 1 ) )
        lib$stop( status );

    sys$dassgn( lat_io_channel );

    printf( "Lat port: %s, mapped to Server: %s, Port: %s\n",
            lat_device.dsc$a_pointer, srvr_name, port_name );
    printf( "Server port is %s queued\n", q & 1 ? "" : "not" );

}

