Non-blocking sockets on SunOS 4 are blocking

Non-blocking sockets on SunOS 4 are blocking

Post by Michael D'Erri » Fri, 04 Aug 1995 04:00:00



Hello,

I have been using the O_NONBLOCK option to set up non-blocking
sockets under Solaris 2.x, and have tried using the same code
under SunOS 4.1.4 without success.  The code compiles without
errors, but the sockets block forever when send() is called.
This was verified by trace'ing a running process.

In the man page, there is no discussion of O_NONBLOCK, but
/usr/include/sys/fcntlcom.h defines it, and indicates that it
provides POSIX semantics.

What do I need to do to properly set up a non-blocking socket
under SunOS 4?  Use O_NDELAY?  If so, what do I need to watch
out for?  I didn't find much in Stevens' Adv. Prog. in UNIX Env.
except that O_NDELAY sounds like a Bad Thing.

Thanks,

Michael D'Errico
Software.com, Inc.

[In case my news software is still mis-configured, please

 
 
 

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. Dollar Universe for patrol

3. Blocking and Non-Blocking socket

4. SUN' native language

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

6. child process killed on 4.3, not on 4.2

7. Difference between blocking and non-blocking socket ?

8. XFree86-4.0 NVIDIA resolution problem.

9. What is difference of SYNC, ASYNC, BLOCKING, NON-BLOCKING sockets?

10. select() behavior for Blocking and non-blocking sockets.

11. How do I set a non-blocking socket back to blocking?

12. changing socket to blocking after non blocking connect

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