1SOCKATMARK(3P)             POSIX Programmer's Manual            SOCKATMARK(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       sockatmark — determine whether a socket is at the out-of-band mark
14

SYNOPSIS

16       #include <sys/socket.h>
17
18       int sockatmark(int s);
19

DESCRIPTION

21       The sockatmark() function shall determine whether the socket  specified
22       by  the  descriptor  s  is  at  the  out-of-band data mark (see Section
23       2.10.12, Socket Out-of-Band Data  State).   If  the  protocol  for  the
24       socket  supports out-of-band data by marking the stream with an out-of-
25       band data mark, the sockatmark() function shall return 1 when all  data
26       preceding  the  mark has been read and the out-of-band data mark is the
27       first element in the receive queue. The sockatmark() function shall not
28       remove the mark from the stream.
29

RETURN VALUE

31       Upon  successful  completion,  the sockatmark() function shall return a
32       value indicating whether the socket is at an out-of-band data mark.  If
33       the protocol has marked the data stream and all data preceding the mark
34       has been read, the return value shall be 1; if there is no mark, or  if
35       data  precedes the mark in the receive queue, the sockatmark() function
36       shall return 0. Otherwise, it shall return a value of −1 and set  errno
37       to indicate the error.
38

ERRORS

40       The sockatmark() function shall fail if:
41
42       EBADF  The s argument is not a valid file descriptor.
43
44       ENOTTY The file associated with the s argument is not a socket.
45
46       The following sections are informative.
47

EXAMPLES

49       None.
50

APPLICATION USAGE

52       The  use of this function between receive operations allows an applica‐
53       tion to determine which received data precedes the out-of-band data and
54       which follows the out-of-band data.
55
56       There  is an inherent race condition in the use of this function. On an
57       empty receive queue, the current read of the location might well be  at
58       the  ``mark'',  but the system has no way of knowing that the next data
59       segment that will arrive from the network  will  carry  the  mark,  and
60       sockatmark()  will  return  false,  and  the  next  read operation will
61       silently consume the mark.
62
63       Hence, this function can only be used  reliably  when  the  application
64       already  knows that the out-of-band data has been seen by the system or
65       that it is known that there is data waiting to be read  at  the  socket
66       (via  SIGURG  or select()).  See Section 2.10.11, Socket Receive Queue,
67       Section 2.10.12, Socket Out-of-Band Data State, Section  2.10.14,  Sig‐
68       nals, and pselect() for details.
69

RATIONALE

71       The sockatmark() function replaces the historical SIOCATMARK command to
72       ioctl() which implemented the same functionality  on  many  implementa‐
73       tions.  Using  a  wrapper  function  follows the adopted conventions to
74       avoid specifying commands to the ioctl() function, other than those now
75       included  to  support  XSI  STREAMS. The sockatmark() function could be
76       implemented as follows:
77
78           #include <sys/ioctl.h>
79
80           int sockatmark(int s)
81           {
82               int val;
83               if (ioctl(s,SIOCATMARK,&val)==−1)
84                   return(−1);
85               return(val);
86           }
87
88       The use of [ENOTTY] to indicate an incorrect  descriptor  type  matches
89       the historical behavior of SIOCATMARK.
90

FUTURE DIRECTIONS

92       None.
93

SEE ALSO

95       Section  2.10.12,  Socket  Out-of-Band  Data  State, pselect(), recv(),
96       recvmsg()
97
98       The Base Definitions volume of POSIX.1‐2008, <sys_socket.h>
99
101       Portions of this text are reprinted and reproduced in  electronic  form
102       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
103       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
104       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
105       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
106       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
107       event of any discrepancy between this version and the original IEEE and
108       The  Open Group Standard, the original IEEE and The Open Group Standard
109       is the referee document. The original Standard can be  obtained  online
110       at http://www.unix.org/online.html .
111
112       Any  typographical  or  formatting  errors that appear in this page are
113       most likely to have been introduced during the conversion of the source
114       files  to  man page format. To report such errors, see https://www.ker
115       nel.org/doc/man-pages/reporting_bugs.html .
116
117
118
119IEEE/The Open Group                  2013                       SOCKATMARK(3P)
Impressum