1SOCKATMARK(3P) POSIX Programmer's Manual SOCKATMARK(3P)
2
3
4
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
12 sockatmark - determine whether a socket is at the out-of-band mark
13
15 #include <sys/socket.h>
16
17 int sockatmark(int s);
18
19
21 The sockatmark() function shall determine whether the socket specified
22 by the descriptor s is at the out-of-band data mark (see the System
23 Interfaces volume of IEEE Std 1003.1-2001, Section 2.10.12, Socket Out-
24 of-Band State). If the protocol for the socket supports out-of-band
25 data by marking the stream with an out-of-band data mark, the sockat‐
26 mark() function shall return 1 when all data preceding the mark has
27 been read and the out-of-band data mark is the first element in the
28 receive queue. The sockatmark() function shall not remove the mark from
29 the stream.
30
32 Upon successful completion, the sockatmark() function shall return a
33 value indicating whether the socket is at an out-of-band data mark. If
34 the protocol has marked the data stream and all data preceding the mark
35 has been read, the return value shall be 1; if there is no mark, or if
36 data precedes the mark in the receive queue, the sockatmark() function
37 shall return 0. Otherwise, it shall return a value of -1 and set errno
38 to indicate the error.
39
41 The sockatmark() function shall fail if:
42
43 EBADF The s argument is not a valid file descriptor.
44
45 ENOTTY The s argument does not specify a descriptor for a socket.
46
47
48 The following sections are informative.
49
51 None.
52
54 The use of this function between receive operations allows an applica‐
55 tion to determine which received data precedes the out-of-band data and
56 which follows the out-of-band data.
57
58 There is an inherent race condition in the use of this function. On an
59 empty receive queue, the current read of the location might well be at
60 the "mark", but the system has no way of knowing that the next data
61 segment that will arrive from the network will carry the mark, and
62 sockatmark() will return false, and the next read operation will
63 silently consume the mark.
64
65 Hence, this function can only be used reliably when the application
66 already knows that the out-of-band data has been seen by the system or
67 that it is known that there is data waiting to be read at the socket
68 (via SIGURG or select()). See Socket Receive Queue, Socket Out-of-Band
69 Data State, Signals, and pselect() for details.
70
72 The sockatmark() function replaces the historical SIOCATMARK command to
73 ioctl() which implemented the same functionality on many implementa‐
74 tions. Using a wrapper function follows the adopted conventions to
75 avoid specifying commands to the ioctl() function, other than those now
76 included to support XSI STREAMS. The sockatmark() function could be
77 implemented as follows:
78
79
80 #include <sys/ioctl.h>
81
82
83 int sockatmark(int s)
84 {
85 int val;
86 if (ioctl(s,SIOCATMARK,&val)==-1)
87 return(-1);
88 return(val);
89 }
90
91 The use of [ENOTTY] to indicate an incorrect descriptor type matches
92 the historical behavior of SIOCATMARK.
93
95 None.
96
98 pselect(), recv(), recvmsg(), the Base Definitions volume of
99 IEEE Std 1003.1-2001, <sys/socket.h>
100
102 Portions of this text are reprinted and reproduced in electronic form
103 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
104 -- Portable Operating System Interface (POSIX), The Open Group Base
105 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
106 Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/online.html .
111
112
113
114IEEE/The Open Group 2003 SOCKATMARK(3P)