HELP - Non-blocking sockets

HELP - Non-blocking sockets

Post by John Patrick Arnol » Thu, 24 Oct 1996 04:00:00



I think I know the answer to this question, but I
will ask anyway. I have an application that requires
reading and writing through IP/STREAMS sockets. Right
now I have the application doing a non-blocking read
and write through a serial port, which makes it very
simple. Does anyone know of a way to open/create a
non-blocking socket?

I already have gone looked at setsockopt () and
ioctl (), and neither offers what I need.

If it's not possible to do this, I would like to see
this documented somewhere.

Thanking you in advance,

John P. Arnold
SKYDATA, Inc
7780 Technology Drive
West Melbourne, FL 32904

 
 
 

HELP - Non-blocking sockets

Post by m.. » Thu, 24 Oct 1996 04:00:00



Quote:>I think I know the answer to this question, but I
>will ask anyway. I have an application that requires
>reading and writing through IP/STREAMS sockets. Right
>now I have the application doing a non-blocking read
>and write through a serial port, which makes it very
>simple. Does anyone know of a way to open/create a
>non-blocking socket?

>I already have gone looked at setsockopt () and
>ioctl (), and neither offers what I need.

>If it's not possible to do this, I would like to see
>this documented somewhere.

I just do the socket read with a QIO rather than a QIOW and it works fine.

-- Mike "of course, if you aren't using OpenVMS, that's a problem..." Bartman --

==============================================================================
| I didn't really say all the things that I said.  You probably didn't read  |
| what you thought you read.  Statistics show that this whole thing is more  |
| than likely just a hideous misunderstanding.                               |
==============================================================================

==============================================================================
You can't start from scratch unless you have some.
------------------------------------------------------------------------------

 
 
 

HELP - Non-blocking sockets

Post by tda.. » Thu, 24 Oct 1996 04:00:00



  <snip>
> Does anyone know of a way to open/create a non-blocking socket?
  <snip>
> Thanking you in advance,

> John P. Arnold
> SKYDATA, Incioctl(_socket, FIONBIO, (char *)&nonBlock);
> 7780 Technology Drive
> West Melbourne, FL 32904

One way is to do this:
   int nonBlock = 1;
   ioctl(_socket, FIONBIO, (char *)&nonBlock);

Another way is this:
   int val;
   val = fcntl(_socket, F_GETFL, 0);  /* get current flags */
       val |= O_NONBLOCK;             /* set NONBLOCK bit  */

   fcntl(_socket, F_SETFL, val);      /* set flags on socket */

Where _socket is the fd of the socket.

 
 
 

HELP - Non-blocking sockets

Post by Scott Sanbe » Fri, 25 Oct 1996 04:00:00



>...
> simple. Does anyone know of a way to open/create a
> non-blocking socket?

Take a look at O_NONBLOCK for open(), and then read(), write().
Scott
--

interGlobe Networks, Inc.               OFFICE: 206.623.2222
1520 Fourth Avenue, Suite 200           FAX: 206.623.0885

This is my opinion and mine alone.      URL: http://www.interglobe.com
 
 
 

1. Blocking and Non-Blocking socket

Hi,

I have a socket that I use for read/write. When created, the socket is
blocking by default. I want it to be blocking sometimes and
non-blocking other times. I have succeeded in switching from Blocking
to Non-blocking using

      fcntl(socket, F_SETFL, O_NONBLOCK);

but now I want to set it back to blocking. Is there something like

      fcntl(socket, F_SETFL, O_BLOCK);

around? I cannot find a way to set it back to blocking. Thanks for any
suggestions!

-Chris

2. POSIX gurus: an 'environ' declaration question

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

4. Trouble booting Linux

5. Difference between blocking and non-blocking socket ?

6. Problem with Acrobat Reader installation

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

8. Looking for a replacement for login

9. Non-blocking sockets on SunOS 4 are blocking

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

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

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

13. Non-blocking socket IO (HELP?)