Solaris 2.3 Non-blocking woes

Solaris 2.3 Non-blocking woes

Post by Mahesh Neelakan » Sun, 06 Nov 1994 10:43:01

Here's a good one:
   I am trying to use setsockopt and/or getsockopt on a _non-blocking_ AF_INET
socket under Solaris 2.3. Unfortunately, for some reason, if I give it an
destination IP address (or a destination address that is real far away),
solaris just hangs/blocks on the call! I've tried the same code
on a BSD/386 1.1 machine and a RS/6000 and both return right back from
[sg]etsockopt with a EINPROGRESS (i.e. connection is still being established).

Also, under SunOS 4.1, I can't seem to do the FIONBIO on the says
Operation not permitted on there some other method for SunOS?

The code below takes two arguments, your local IP and the destination IP
(ex: ./socktest Under solaris, the code will
block on the sockopt functions.

I've applied the OS patches from to my sparc and one of those
patches mentioned blocking on reads on non-blocking sockets but to no avail.
Any help/input greatly appreciated!


#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <sys/filio.h> /* Only for Solaris and SunOS */
#include <sys/ioctl.h>

int argc,
char *argv[])
     int sockfd;
     int nonblk;
     int winsiz;
     int len;
     struct sockaddr_in myaddr;
     struct sockaddr_in rhaddr;

     if (argc < 3) {
     if ((sockfd=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) < 0) {

     if (ioctl(sockfd,FIONBIO,&nonblk) < 0) {


     if (bind(sockfd,(struct sockaddr *)&myaddr,sizeof(myaddr)) < 0) {

     if (connect(sockfd,(struct sockaddr *)&rhaddr,sizeof(rhaddr)) < 0) {
          if (errno != EINPROGRESS) {

     fprintf(stderr,"Getting buffer sizes.\n");
     if (getsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,(char*)winsiz,&len) < 0) {
     if (errno) {
     fprintf(stderr,"Send buffer size=%d\n",winsiz);
     if (getsockopt(sockfd,SOL_SOCKET,SO_RCVBUF,(char*)winsiz,&len) < 0) {
     if (errno) {
     fprintf(stderr,"Recv buffer size=%d\n",winsiz);



1. HELP: non-blocking read Solaris 2.3 /dev/bpp0

On Solaris 2.3 with Sparc 10:

Can someone please suggest a sensible way to check if characters are
waiting to be read from an I/O channel?

I would like to be able to do an fopen on /dev/bpp0 (the parallel port)
and see if there are any characters waiting to be read.  Or some kind of
non-blocking read would be OK also.  What is the technique required
under Solaris 2.x?

2. SMC EtherPower Installation?

3. solaris 2.3 non blocking sockets issues

4. mouse cursor jump when CPU busy

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

6. new 2.5.72 breaks aumix

7. Blocking and Non-Blocking socket

8. Error compiling Libvga-1.2.9

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

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

11. [2.5] Non-blocking write can block

12. Blocking & Non-Blocking

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