1sockatmark(3)              Library Functions Manual              sockatmark(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

34       EBADF  sockfd is not a valid file descriptor.
35
36       EINVAL sockfd is not a file descriptor to which sockatmark() can be ap‐
37              plied.
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

STANDARDS

50       POSIX.1-2008.
51

HISTORY

53       glibc 2.2.4.  POSIX.1-2001.
54

NOTES

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

BUGS

66       Prior to glibc 2.4, sockatmark() did not work.
67

EXAMPLES

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

SEE ALSO

102       fcntl(2), recv(2), send(2), tcp(7)
103
104
105
106Linux man-pages 6.04              2023-03-30                     sockatmark(3)
Impressum