CINXE.COM

sockatmark

<html> <head> <title>sockatmark</title> <META NAME="KEYWORDS" CONTENT="sockatmark"> </head> <body BGCOLOR="#ffffff" LINK="#0000ff" VLINK="#0000ff" ALINK="#0000ff" TEXT="#000000"> <center> <h1><b>sockatmark</b></h1></center> <PRE> <STRONG><A HREF="/man3/SOCKATMARK">SOCKATMARK(3)</A></STRONG> Linux Programmer's Manual <STRONG><A HREF="/man3/SOCKATMARK">SOCKATMARK(3)</A></STRONG> NAME sockatmark - determine whether socket is at out-of-band mark SYNOPSIS #include &lt;sys/socket.h&gt; int sockatmark(int sockfd); Feature Test Macro Requirements for glibc (see <STRONG><A HREF="/man7/feature_test_macros">feature_test_macros(7)</A></STRONG>): sockatmark(): _POSIX_C_SOURCE &gt;= 200112L DESCRIPTION sockatmark() returns a value indicating whether or not the socket re- ferred to by the file descriptor sockfd 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. RETURN VALUE A successful call to sockatmark() returns 1 if the socket is at the out-of-band mark, or 0 if it is not. On error, -1 is returned and er- rno is set to indicate the error. ERRORS EBADF sockfd is not a valid file descriptor. EINVAL sockfd is not a file descriptor to which sockatmark() can be ap- plied. VERSIONS sockatmark() was added to glibc in version 2.2.4. ATTRIBUTES For an explanation of the terms used in this section, see at- <STRONG><A HREF="/man7/tributes">tributes(7)</A></STRONG>. +-------------+---------------+---------+ |Interface | Attribute | Value | +-------------+---------------+---------+ |sockatmark() | Thread safety | MT-Safe | +-------------+---------------+---------+ CONFORMING TO POSIX.1-2001, POSIX.1-2008. NOTES If sockatmark() returns 1, then the out-of-band data can be read using the MSG_OOB flag of <STRONG><A HREF="/man2/recv">recv(2)</A></STRONG>. Out-of-band data is supported only on some stream socket protocols. sockatmark() can safely be called from a handler for the SIGURG signal. sockatmark() is implemented using the SIOCATMARK <STRONG><A HREF="/man2/ioctl">ioctl(2)</A></STRONG> operation. BUGS Prior to glibc 2.4, sockatmark() did not work. EXAMPLE The following code can be used after receipt of a SIGURG signal to read (and discard) all data up to the mark, and then read the byte of data at the mark: char buf[BUF_LEN]; char oobdata; int atmark, s; for (;;) { atmark = sockatmark(sockfd); if (atmark == -1) { perror("sockatmark"); break; } if (atmark) break; s = read(sockfd, buf, BUF_LEN); if (s == -1) perror("read"); if (s &lt;= 0) break; } if (atmark == 1) { if (recv(sockfd, &amp;oobdata, 1, MSG_OOB) == -1) { perror("recv"); ... } } SEE ALSO <STRONG><A HREF="/man2/fcntl">fcntl(2)</A></STRONG>, <STRONG><A HREF="/man2/recv">recv(2)</A></STRONG>, <STRONG><A HREF="/man2/send">send(2)</A></STRONG>, <STRONG><A HREF="/man7/tcp">tcp(7)</A></STRONG> COLOPHON This page is part of release 5.05 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 <STRONG><A HREF="/man3/SOCKATMARK">SOCKATMARK(3)</A></STRONG></PRE> <center> <h6>Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2025 <a href="http://www.he.net">Hurricane Electric</a>. All Rights Reserved.</h6></center> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10