1SOCKATMARK(3)              Linux Programmer's Manual             SOCKATMARK(3)
2
3
4

NAME

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

SYNOPSIS

9       #include <sys/socket.h>
10
11       int sockatmark(int sockfd);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       sockatmark():
16           _POSIX_C_SOURCE >= 200112L
17

DESCRIPTION

19       sockatmark()  returns  a value indicating whether or not the socket re‐
20       ferred to by the file descriptor sockfd is at the out-of-band mark.  If
21       the  socket is at the mark, then 1 is returned; if the socket is not at
22       the mark, 0 is returned.  This function does not remove the out-of-band
23       mark.
24

RETURN VALUE

26       A  successful  call  to  sockatmark() returns 1 if the socket is at the
27       out-of-band mark, or 0 if it is not.  On error, -1 is returned and  er‐
28       rno is set to indicate the error.
29

ERRORS

31       EBADF  sockfd is not a valid file descriptor.
32
33       EINVAL sockfd is not a file descriptor to which sockatmark() can be ap‐
34              plied.
35

VERSIONS

37       sockatmark() was added to glibc in version 2.2.4.
38

ATTRIBUTES

40       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
41       tributes(7).
42
43       ┌────────────────────────────────────────────┬───────────────┬─────────┐
44Interface                                   Attribute     Value   
45       ├────────────────────────────────────────────┼───────────────┼─────────┤
46sockatmark()                                │ Thread safety │ MT-Safe │
47       └────────────────────────────────────────────┴───────────────┴─────────┘
48

CONFORMING TO

50       POSIX.1-2001, POSIX.1-2008.
51

NOTES

53       If  sockatmark() returns 1, then the out-of-band data can be read using
54       the MSG_OOB flag of recv(2).
55
56       Out-of-band data is supported only on some stream socket protocols.
57
58       sockatmark() can safely be called from a handler for the SIGURG signal.
59
60       sockatmark() is implemented using the SIOCATMARK ioctl(2) operation.
61

BUGS

63       Prior to glibc 2.4, sockatmark() did not work.
64

EXAMPLES

66       The following code can be used after receipt of a SIGURG signal to read
67       (and  discard)  all data up to the mark, and then read the byte of data
68       at the mark:
69
70           char buf[BUF_LEN];
71           char oobdata;
72           int atmark, s;
73
74           for (;;) {
75               atmark = sockatmark(sockfd);
76               if (atmark == -1) {
77                   perror("sockatmark");
78                   break;
79               }
80
81               if (atmark)
82                   break;
83
84               s = read(sockfd, buf, BUF_LEN);
85               if (s == -1)
86                   perror("read");
87               if (s <= 0)
88                   break;
89           }
90
91           if (atmark == 1) {
92               if (recv(sockfd, &oobdata, 1, MSG_OOB) == -1) {
93                   perror("recv");
94                   ...
95               }
96           }
97

SEE ALSO

99       fcntl(2), recv(2), send(2), tcp(7)
100

COLOPHON

102       This page is part of release 5.13 of the Linux  man-pages  project.   A
103       description  of  the project, information about reporting bugs, and the
104       latest    version    of    this    page,    can     be     found     at
105       https://www.kernel.org/doc/man-pages/.
106
107
108
109Linux                             2021-03-22                     SOCKATMARK(3)
Impressum