Subject: | |
From: | |
Reply To: | |
Date: | Thu, 6 Aug 1998 08:07:34 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Just a wild guess. Select uses HPSELECT and HPSELECT is only supposed to
support NETIPC files. So on the console or any other hardwired terminal
I would expect select to return true for the file descriptor as that is
what the documentation says will happen. Maybe when connected via
telnet, it sort if works because the programs input file is really a
socket. But since the i/o is handled before you see it, it always times
out. I tried it on a VT session and the same thing happened. I don't
think you can use select for terminal input, try using nowait i/o.
John Zoltak
North American Mfg Co
> -----Original Message-----
> From: Ian Collins [SMTP:[log in to unmask]]
> Sent: Wednesday, August 05, 1998 10:54 PM
> To: [log in to unmask]
> Subject: [HP3000-L] HELP - MPE 5.5 socket select call
>
> PLEASE - can someone tell me why the following trivial C program does
> not work on MPE 5.5.
> It was compiled in the native environment using CCXL and linked using:
>
> link from=junk.o,libc.lib.sys,socketrl.net.sys;to=junk
>
> If I run this program on the master console, I can READ but never get
> TIMEOUTS
> and if I run it from a telnet session, I can get TIMEOUTS but no
> READS!
>
> I'm reaching the end of my tether. It should be such a trivial
> excercise
> :-)
>
> /* ------ snip ------ */
>
> #define _SOCKET_SOURCE
>
> #include <stdio.h>
>
> #include <string.h>
>
> #include <errno.h>
>
> #include <sys/types.h>
>
> #include <sys/socket.h>
>
> #include <netinet/in.h>
>
> #include <netdb.h>
>
> #include <time.h>
>
>
>
> main() {
>
> int iret;
>
> struct fd_set readfds;
>
> struct timeval timeout;
>
> int nfound;
>
> int ok;
>
> int i;
>
> char c[1];
>
>
>
> while (1) {
>
> FD_ZERO(&readfds);
>
> FD_SET(0,&readfds);
>
> timeout.tv_sec=5; /* 5 second timeout */
> timeout.tv_usec= 0;
>
> nfound = select( 1, &readfds, 0, 0, &timeout);
>
> if( nfound == -1 ){
>
> printf("select returned -1 oops \n");
>
> break;
>
> }
>
> else if (nfound == 0){
>
> printf("Select timed out \n");
>
> }
>
> else {
>
> printf("Select thinks there is something to read \n");
>
> i = read(0, c, 1);
>
> printf("Read %c\n", c[0]);
>
> if (c[0] == 81) break;
>
> }
>
> }
>
> }
|
|
|