Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!portal!exloghou!dave From: dave@exloghou.portal.com (Dave St.Clair) Newsgroups: comp.windows.x Subject: Re: XTerminals and bar-code readers Summary: NCD serial port Message-ID: <1991Apr3.144425.12207@exloghou.portal.com> Date: 3 Apr 91 14:44:25 GMT References: <1556502476@corona.med.utah.edu> Organization: Exploration Logging, Inc. Lines: 59 > Can anyone verify whether or not a bar code wand can be stuck on an > XTerminal (NCD. DEC). They are typically inserted inline on char. > based terminals and pcs. We use NCD 17/14c Xterminals in our application and hook the serial port to a variety of devices. The port is easily accessed via a socket from a host machine (I think its number is 87). Once you've connected to the socket you can do whatever you like. Here's a portion of the code which opens the socket (On a Sun Sparc 2 running SunOS 4.1.1, NCD 17c software version 2.2.2D) ... #include #include #include #include #include #define NCDPORTNUM 87 .... fd = xserial(NCDPORTNUM, ncdname); ...... int xserial(int portnum, char *hostname) { struct sockaddr_in sin; = { AF_INET }; struct hostent *host; sin.sin_port = htons((u_short)(portnum)); sin.sin_family = AF_INET; if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) return(FAILURE); if((host = gethostbyname(hostname)) == (struct hostent *)0) return(FAILURE); sin.sin_family = host->h_addrtype; bcopy(host->h_addr, (caddr_t)&sin.sin_addr, host->h_length); if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) < 0) { close(s); return(FAILURE); } (void)fcntl(s, F_SETFL,O_NDELAY); /* set to non-blocking */ return(s); } Dave St.Clair dave@exloghou.portal.com