233 lines
6.1 KiB
HTML
233 lines
6.1 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SOCKATMARK</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SOCKATMARK</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sockatmark - determine whether socket is at out-of-band mark
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sys/socket.h">sys/socket.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int sockatmark(int </B><I>sockfd</I><B>);</B>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>sockatmark</B>():
|
|
|
|
_POSIX_C_SOURCE >= 200112L
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>sockatmark</B>()
|
|
|
|
returns a value indicating whether or not the socket referred
|
|
to by the file descriptor
|
|
<I>sockfd</I>
|
|
|
|
is at the out-of-band mark.
|
|
If the socket is at the mark, then 1 is returned;
|
|
if the socket is not at the mark, 0 is returned.
|
|
This function does not remove the out-of-band mark.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
A successful call to
|
|
<B>sockatmark</B>()
|
|
|
|
returns 1 if the socket is at the out-of-band mark, or 0 if it is not.
|
|
On error, -1 is returned and
|
|
<I>errno</I>
|
|
|
|
is set to indicate the error.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EBADF</B>
|
|
|
|
<DD>
|
|
<I>sockfd</I>
|
|
|
|
is not a valid file descriptor.
|
|
<DT id="2"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
|
|
<I>sockfd</I>
|
|
|
|
is not a file descriptor to which
|
|
<B>sockatmark</B>()
|
|
|
|
can be applied.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
<B>sockatmark</B>()
|
|
|
|
was added to glibc in version 2.2.4.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>sockatmark</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
If
|
|
<B>sockatmark</B>()
|
|
|
|
returns 1, then the out-of-band data can be read using the
|
|
<B>MSG_OOB</B>
|
|
|
|
flag of
|
|
<B><A HREF="/cgi-bin/man/man2html?2+recv">recv</A></B>(2).
|
|
|
|
<P>
|
|
|
|
Out-of-band data is supported only on some stream socket protocols.
|
|
<P>
|
|
|
|
<B>sockatmark</B>()
|
|
|
|
can safely be called from a handler for the
|
|
<B>SIGURG</B>
|
|
|
|
signal.
|
|
<P>
|
|
|
|
<B>sockatmark</B>()
|
|
|
|
is implemented using the
|
|
<B>SIOCATMARK</B>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl">ioctl</A></B>(2)
|
|
|
|
operation.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
Prior to glibc 2.4,
|
|
<B>sockatmark</B>()
|
|
|
|
did not work.
|
|
<A NAME="lbAL"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
The following code can be used after receipt of a
|
|
<B>SIGURG</B>
|
|
|
|
signal to read (and discard) all data up to the mark,
|
|
and then read the byte of data at the mark:
|
|
<P>
|
|
|
|
|
|
<BR> char buf[BUF_LEN];
|
|
<BR> char oobdata;
|
|
<BR> int atmark, s;
|
|
<P>
|
|
<BR> for (;;) {
|
|
<BR> atmark = sockatmark(sockfd);
|
|
<BR> if (atmark == -1) {
|
|
<BR> perror("sockatmark");
|
|
<BR> break;
|
|
<BR> }
|
|
<P>
|
|
<BR> if (atmark)
|
|
<BR> break;
|
|
<P>
|
|
<BR> s = read(sockfd, buf, BUF_LEN);
|
|
<BR> if (s == -1)
|
|
<BR> perror("read");
|
|
<BR> if (s <= 0)
|
|
<BR> break;
|
|
<BR> }
|
|
<P>
|
|
<BR> if (atmark == 1) {
|
|
<BR> if (recv(sockfd, &oobdata, 1, MSG_OOB) == -1) {
|
|
<BR> perror("recv");
|
|
<BR> ...
|
|
<BR> }
|
|
<BR> }
|
|
|
|
<A NAME="lbAM"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fcntl">fcntl</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+recv">recv</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+send">send</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+tcp">tcp</A></B>(7)
|
|
|
|
<A NAME="lbAN"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="6"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="7"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="8"><A HREF="#lbAG">VERSIONS</A><DD>
|
|
<DT id="9"><A HREF="#lbAH">ATTRIBUTES</A><DD>
|
|
<DT id="10"><A HREF="#lbAI">CONFORMING TO</A><DD>
|
|
<DT id="11"><A HREF="#lbAJ">NOTES</A><DD>
|
|
<DT id="12"><A HREF="#lbAK">BUGS</A><DD>
|
|
<DT id="13"><A HREF="#lbAL">EXAMPLE</A><DD>
|
|
<DT id="14"><A HREF="#lbAM">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAN">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:57 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|