From: marinell@mostaccioli.cis.ohio-state.edu (tony marinello)
Subject: VAX C RTL
Organization: The Ohio State University Dept. of Computer and Info. Science
Date: Wed, 30 Dec 1992 17:34:01 GMT

     Can I use c-rtl routines instead of qio's to communicate asynchronously 
between two lat devices?   In this case the devices are a terminal and a 
Hayes modem.  DSN%C gave me the following reply  to this question:

...I have been digging far and wide and have been unable to come up with
any examples using c rtl routines. There is currently no way to do
asynchronous writes using the vax c rtl. There is a "rop=asy" option
that can be specified on an open() or fopen(), but under the current
implementation, only reads are performed asynchronously. This option
corresponds to the rab$v_asy flag.

...which means "yes" for reads(asynchronous) but no for writes.

The following code is an attempt to accomplish this end. In this case there is a
Hayes modem with these characteristics:

Terminal: _LTA125:    Device_Type: Unknown       Owner: No Owner

   Input:   1200      LFfill:  0      Width:  80      Parity: None
   Output:  1200      CRfill:  0      Page:    0

and a terminal with these characteristics:

Terminal: _LTA5050:   Device_Type: VT100         Owner: ME
LAT Server/Port: DIAL/PORT_1

   Input:   9600      LFfill:  0      Width:  80      Parity: None
   Output:  9600      CRfill:  0      Page:   24

$



----------------------------------------- CUT HERE --------------------------------------------
#include stdio
#include unixio
#include file
#include ctype
#include string
#include processes
main ()
  {
    FILE *fp,*wp,*fp2,*wp2,*ifp;
    char buffer[21];
    char buffer2[21];
    int xxx, i,EXITFL=0;
 /* get terminal name from VMS */
    system("@DEV.COM");/* see end of message for this file */
    ifp= fopen("TT.DAT","r");
    fscanf(ifp,"%s",buffer);
    fp = fopen (buffer, "r","rop=asy");/* the terminal */
    wp = fopen (buffer, "w","rop=asy");
    fp2 = fopen ("LTA125:", "r","rop=asy");/* the modem*/
    wp2 = fopen ("LTA125:", "w","rop=asy");
    printf("%s\n",buffer);
    memset(buffer,0,20);
    memset(buffer2,0,20);
    if (fp == NULL)
        perror ("fopen: ");
    /* scans both devices  */
    while (EXITFL!=-1)
        {
        xxx = fread(buffer, 20, 1, fp);
        xxx = fread(buffer2, 20, 1, fp2);
        /* If Read from TT: -write to LAT */
        if (strlen(buffer) >= 1)
                {
                fwrite(buffer, 20, 1, wp2);
                if (strcmp(buffer,"q\n")==0)
                        EXITFL=(-1);
                memset(buffer,0,20);
                }
        /* If READ from LAT-write to TT: */
        if (strlen(buffer2) >= 1)
                {
                fwrite(buffer2, 20, 1, wp);
                memset(buffer2,0,20);
                }
        }
    fclose (fp);
    fclose (wp);
    fclose (wp2);
    fclose (fp2);
    fclose (ifp);
  }     

....which fails miserably as the following shows:

$ run unixio3
_LTA5048:

at

at

at

and the lat device returns...
i6mJ4aB
i6mJ4aB
i6mJ4aB

...trash in other words, however it works fine if both devices are the
same lat device i.e. the same terminal.

If anyone knows if something like this can be done then reply to my
address or the newsgroup. B.T.W., I'll be wearing my finest asbestos 
outer-wear.

-Tony

-marinell@cis.ohio-state.edu
-MARINELLO%ODNVMS.ODIN.ODIN.MRGATE.A1.decnet@osi.odn.ohio.gov
**
In file DEV.COM:

ERR= F$GETDVI("TT:","TT_PHYDEVNAM")
$OPEN/WRITE OUTPUT_FILE  TT.DAT
$WRITE/SYMBOL  OUTPUT_FILE ERR
$CLOSE OUTPUT_FILE         

...one can also use the appropriate system service call too.