how to get blocking i/o after non-blocking???

how to get blocking i/o after non-blocking???

Post by bert thomps » Thu, 04 Jun 1992 20:51:28



hi!

        can someone please answer this simple question:

        after starting blocking i/o with
                fcntl(fileno(stdin), F_SETFL, FNDELAY)
        how do you get i/o to block again???

thanks!

        bert.

 
 
 

1. Non blocking socket blocks; says 'read would block' ?

Hi all,

I have three sockets in server which I am reading in a continuous loop,
so don't want to wait on any one. I have designated them as 'non blocking'
but when run the server exits on the very first read() and says 'would
block'. (Is it the same as 'EWOULDBLOCK' mentioned in R. Steven's book ?)
I don't want that I should get any error msg and exit, in fact the
whole purpose of nonblocking is that if something is available, read it
else proceed in the loop and come back to read next time.
The client (sender) is sending msgs on all three sockets. The sockets
are conn_oriented. I am using SunOS 4.1. The small code part is below:

int emer_s, env_s, sens_s;            /* socket fds */
//----------- making sockets nonblocking ******
if ((res=fcntl(emer_s,F_SETFL,FNDELAY)) < 0)
        {
          perror("fcntl res = -1");
          exit(1);
        }
if ((res=fcntl(env_s,F_SETFL,FNDELAY)) < 0)
        {
          perror("fcntl res = -1");
          exit(1);
        }
if ((res=fcntl(sens_s,F_SETFL,FNDELAY)) < 0)
        {
          perror("fcntl res = -1");
          exit(1);
        }

for(; ;)
   {

      if ((cc=read(emer_s,(char*)&gen_struct,size)) < size)
        {
        perror("read error");
          exit(1);
        }
......... do something
      if ((cc=read(env_s,(char*)&gen_struct,size)) < size)
        {
         perror("read error");
          exit(1);
        }
        ......... do something
      if ((cc=read(sens_s,(char*)&gen_struct,size)) < size)
        {
          perror("read error");
          exit(1);
        }
        ......... do something

   }

Any help is appreciated.

hashmi

--
-----
Atiqullah Hashmi                    
UTA (Univ. of Texas at Arlington)  

2. Solaris Automation experts ! needed in Sunny Scottsdale AZ ! ***

3. Blocking connect() fails, non-blocking succeeds?

4. duplex printing with LPRng/IFHP over Samba

5. Blocking and Non-Blocking socket

6. Problem building procps-0.99a and general upgrade questions

7. [2.2] pipe_write can block even with non-blocking fd

8. Read Error After Installing

9. [2.5] Non-blocking write can block

10. Blocking & Non-Blocking

11. Non-blocking socket reads block! (Bug?)

12. Problem with blocking opens preventing non-blocking opens in AIX 5.2

13. Difference between blocking and non-blocking socket ?