Out-of-band data on sockets - how to detect "true" exceptions ?

Out-of-band data on sockets - how to detect "true" exceptions ?

Post by Nitin H Vaid » Wed, 20 Jul 1994 22:37:18


I have a question regarding the use of "select" system call to detect
the exception condition caused by arrival of "out-of-band" data.
I am running into the following problem (item 4 below describes the
actual problem)

(1) A signal handler is associated with the SIGURG signal. Thus,
    when an out-of-band data arrives, the signal handler is called.
    The signal handler uses the "select" system call to determine
    which sockets have exception conditions. It reads an out-of-band
    byte on each socket that has the exception.
    (using recv(fd, &data, 1, MSG_OOB))
(2) process A and B both send one byte of out-of-band data
    to process C (using send(fd, &data, 1, MSG_OOB)).
(3) The out-of-band data from A arrives first and causes
    the signal handler to be called.
    The socket (say, Sa) connecting C and A is detected to have
    an exception. The signal handler reads a byte (out-of-order)
    from that socket. No exception is detected on the socket
    (say Sb) connecting B and C.

(4) The signal handler is called again when the out-of-band data
    arrives from B to process C.
    There cannot be any pending out-of-order data from A on socket Sa.
    However, when "select" is called, it indicates that BOTH
    sockets Sa and Sb have an exception condition.
    An attempt to recv(fd, &data, 1, MSG_OOB) on socket Sa returns
    error EINVAL (as there is no out-of-band data on that socket).

Should socket Sa show an exception condition when the out-of-band
data has already been read ?
Or, do I have to do something to "clear" the exception condition
after the out-of-band data is read ?

I would appreciate your reply. Please send your reply

- nitin vaidya


1. BSD Sockets and Out-of-Band data

I have 2 questions about sockets. Btw, my system is FreeBSD.

1- When I create a socket, I'm a little confused with the options.
Suppose I create a socket with the following options:

AF_INET, SOCK_xxx: I know what means AF_INET, but I'm confused about
the second one. What do they mean. I know what is a stream and
what is a packet. Does SOCK_STREAM means that there is a stream (maybe
buffered), like stdout and other file streams. Do I have to tell the
other end (the reading end) that I'm finished by closing the socket
(like in a pipe)? That is not the behavior I'm looking for.
I want to write a server that will manage a program that could have
multiple instances and to occasionnally send messages when particular
events occur (an instance has made a change somewhere and the server
would tell the other instances on the LAN, and things like that).
Would it be better to use datagrams? I thought that it would be better
to use TCP/IP sockets, since they provide part of what I'm expecting
from this network communication (reliable connections).

Also, is there a way to know from which machine an incoming connection
comes from?

Btw, if you could point me to a Web Page that tells the relationships
between the 3 parameters of the socket function, I would appreciate it.

2- What happens when Out-of-Band data arrives? On FreeBSD, is it
put on the top of the receiving queue or is it put on another one. I've
read a book ("The design and implementation of the 4.3BSD UNIX OS")
that Out-of-Band data is not placed in the normal queue.


Michel Prvost
Qubec, Canada



2. apache 2.039 Solaris 8 Intel

3. select & out-of-band socket data

4. CGI doesn't display GIF

5. HELP with Sockets using OOB data (Out-Of-Band)

6. opengl with 4d60t on 500au

7. socket out-of-band data

8. dialin/out/up?

9. sockets and out-of-band data

10. out-of-band data on tcp-sockets

11. GETSERVBYNAME()????????????????????"""""""""""""

12. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

13. Advisory: Wintroll detected, "eel_boy is " Austin Rogers" and "andante quok"