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

NAME

6       sockatmark - determine whether a socket is at the out-of-band mark
7

SYNOPSIS

9       #include <sys/socket.h>
10
11       int sockatmark(int s);
12
13

DESCRIPTION

15       The  sockatmark() function shall determine whether the socket specified
16       by the descriptor s is at the out-of-band data  mark  (see  the  System
17       Interfaces volume of IEEE Std 1003.1-2001, Section 2.10.12, Socket Out-
18       of-Band State). If the protocol for  the  socket  supports  out-of-band
19       data  by  marking the stream with an out-of-band data mark, the sockat‐
20       mark() function shall return 1 when all data  preceding  the  mark  has
21       been  read  and  the  out-of-band data mark is the first element in the
22       receive queue. The sockatmark() function shall not remove the mark from
23       the stream.
24

RETURN VALUE

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

ERRORS

35       The sockatmark() function shall fail if:
36
37       EBADF  The s argument is not a valid file descriptor.
38
39       ENOTTY The s argument does not specify a descriptor for a socket.
40
41
42       The following sections are informative.
43

EXAMPLES

45       None.
46

APPLICATION USAGE

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

RATIONALE

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

FUTURE DIRECTIONS

89       None.
90

SEE ALSO

92       pselect() , recv()  ,  recvmsg()  ,  the  Base  Definitions  volume  of
93       IEEE Std 1003.1-2001, <sys/socket.h>
94
96       Portions  of  this text are reprinted and reproduced in electronic form
97       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
98       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
99       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
100       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
101       event of any discrepancy between this version and the original IEEE and
102       The  Open Group Standard, the original IEEE and The Open Group Standard
103       is the referee document. The original Standard can be  obtained  online
104       at http://www.opengroup.org/unix/online.html .
105
106
107
108IEEE/The Open Group                  2003                        SOCKATMARK(P)
Impressum