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(): _POSIX_C_SOURCE >= 200112L
16

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

VERSIONS

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

ATTRIBUTES

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

CONFORMING TO

48       POSIX.1-2001, POSIX.1-2008.
49

NOTES

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

BUGS

61       Prior to glibc 2.4, sockatmark() did not work.
62

EXAMPLES

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

SEE ALSO

97       fcntl(2), recv(2), send(2), tcp(7)
98

COLOPHON

100       This page is part of release 5.10 of the Linux  man-pages  project.   A
101       description  of  the project, information about reporting bugs, and the
102       latest    version    of    this    page,    can     be     found     at
103       https://www.kernel.org/doc/man-pages/.
104
105
106
107Linux                             2020-06-09                     SOCKATMARK(3)
Impressum