07-13-07 06:22 AM
On Jul 12, 7:45 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article <f7526c$pc...@daniel-new.mch.sbs.de>,
> Rainer Temme <Rainer_Te...@nospam.hotmail_dot_com> wrote:
>
By default, the sockets API does not permit the OOB data to be read
via read(). You have to use a recv* function with the MSG_OOB flag.
That can be changed using the SO_OOBINLINE socket option. I strongly
advise you to go read chapter 21 of W. Richard Stevens's "UNIX Network
Programming, volume 1: Networking APIs: Sockets and XTI", wherein all
the details are discussed and demonstrated.
...[vbcol=seagreen]
>
> Which is what the sockets API does.
Uh, are you really saying that the socket's API stores the normal data
that came before the urgent data and delivers it after the urgent
data? Rainer was saying that the *application* can do that.
>
> AFAIK, the sockets API doesn't provide any way for an
> application to do this, because you don't get access to the
> urgent pointer itself.
Using the SIOCCATMARK ioctl(), the application can determine whether
the read position is at the urgent pointer. Note that the read
position will never 'skip over' the urgent pointer, as read() will
return less than requested rather than do that. (Some newer systems
provide a sockatmark() function to do this, as specified by the Single
Unix Spec, but it isn't as widely implemented as the ioctl(), so
you're better off with the ioctl(), at least for now.)
Alternatively, the application can try to read the OOB data using
recv() with the MSG_OOB flag: if the data hasn't arrived yet then
it'll return EWOULDBLOCK. The application can read (and either toss
or save) another buffer's worth of normal data and then try again.
[vbcol=seagreen]
And note that it can either ignore the data by treating it as normal
(by setting the SO_OOBINLINE socket option) or by never reading it
from the kernel's OOB buffer.
Philip Guenther
[ Post a follow-up to this message ]
|