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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

48       None.
49

APPLICATION USAGE

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

RATIONALE

70       The sockatmark() function replaces the historical SIOCATMARK command to
71       ioctl() which implemented the same functionality  on  many  implementa‐
72       tions.  Using  a  wrapper  function  follows the adopted conventions to
73       avoid specifying commands to the ioctl() function, other than those now
74       included  to  support  XSI  STREAMS. The sockatmark() function could be
75       implemented as follows:
76
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‐2017, <sys_socket.h>
99
101       Portions of this text are reprinted and reproduced in  electronic  form
102       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
103       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
104       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
105       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
106       event of any discrepancy between this version and the original IEEE and
107       The Open Group Standard, the original IEEE and The Open Group  Standard
108       is  the  referee document. The original Standard can be obtained online
109       at http://www.opengroup.org/unix/online.html .
110
111       Any typographical or formatting errors that appear  in  this  page  are
112       most likely to have been introduced during the conversion of the source
113       files to man page format. To report such errors,  see  https://www.ker
114       nel.org/doc/man-pages/reporting_bugs.html .
115
116
117
118IEEE/The Open Group                  2017                       SOCKATMARK(3P)
Impressum