]>
Commit | Line | Data |
---|---|---|
616c2730 | 1 | .\" Copyright (c) 2006, Michael Kerrisk <mtk.manpages@gmail.com> |
21008754 | 2 | .\" |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
21008754 MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
12 | .\" | |
13 | .\" Since the Linux kernel and libraries are constantly changing, this | |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
10d76543 MK |
16 | .\" the use of the information contained herein. The author(s) may not |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
21008754 MK |
20 | .\" |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
21008754 | 24 | .\" |
4b8c67d9 | 25 | .TH SOCKATMARK 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
21008754 MK |
26 | .SH NAME |
27 | sockatmark \- determine whether socket is at out-of-band mark | |
28 | .SH SYNOPSIS | |
29 | .B #include <sys/socket.h> | |
68e4db0a | 30 | .PP |
c4e7b714 | 31 | .BI "int sockatmark(int " sockfd ); |
68e4db0a | 32 | .PP |
cc4615cc MK |
33 | .in -4n |
34 | Feature Test Macro Requirements for glibc (see | |
35 | .BR feature_test_macros (7)): | |
36 | .in | |
68e4db0a | 37 | .PP |
cc4615cc MK |
38 | .ad l |
39 | .BR sockatmark (): | |
a446ac0c | 40 | _POSIX_C_SOURCE\ >=\ 200112L |
cc4615cc | 41 | .ad b |
21008754 MK |
42 | .SH DESCRIPTION |
43 | .BR sockatmark () | |
c13182ef | 44 | returns a value indicating whether or not the socket referred |
21008754 | 45 | to by the file descriptor |
c4e7b714 | 46 | .I sockfd |
21008754 MK |
47 | is at the out-of-band mark. |
48 | If the socket is at the mark, then 1 is returned; | |
49 | if the socket is not at the mark, 0 is returned. | |
50 | This function does not remove the out-of-band mark. | |
47297adb | 51 | .SH RETURN VALUE |
21008754 MK |
52 | A successful call to |
53 | .BR sockatmark () | |
54 | returns 1 if the socket is at the out-of-band mark, or 0 if it is not. | |
c6fa0841 MK |
55 | On error, \-1 is returned and |
56 | .I errno | |
57 | is set to indicate the error. | |
21008754 MK |
58 | .SH ERRORS |
59 | .TP | |
60 | .B EBADF | |
c4e7b714 | 61 | .I sockfd |
21008754 MK |
62 | is not a valid file descriptor. |
63 | .TP | |
64 | .B EINVAL | |
65 | .\" POSIX.1 says ENOTTY for this case | |
c4e7b714 | 66 | .I sockfd |
21008754 MK |
67 | is not a file descriptor to which |
68 | .BR sockatmark () | |
69 | can be applied. | |
2b2581ee MK |
70 | .SH VERSIONS |
71 | .BR sockatmark () | |
72 | was added to glibc in version 2.2.4. | |
662c4b2a | 73 | .SH ATTRIBUTES |
348adff3 PH |
74 | For an explanation of the terms used in this section, see |
75 | .BR attributes (7). | |
76 | .TS | |
77 | allbox; | |
78 | lb lb lb | |
79 | l l l. | |
80 | Interface Attribute Value | |
81 | T{ | |
662c4b2a | 82 | .BR sockatmark () |
348adff3 PH |
83 | T} Thread safety MT-Safe |
84 | .TE | |
47297adb | 85 | .SH CONFORMING TO |
ff976a9e | 86 | POSIX.1-2001, POSIX.1-2008. |
21008754 MK |
87 | .SH NOTES |
88 | If | |
89 | .BR sockatmark () | |
c13182ef | 90 | returns 1, then the out-of-band data can be read using the |
21008754 MK |
91 | .B MSG_OOB |
92 | flag of | |
93 | .BR recv (2). | |
847e0d88 | 94 | .PP |
33a0ccb2 | 95 | Out-of-band data is supported only on some stream socket protocols. |
847e0d88 | 96 | .PP |
21008754 | 97 | .BR sockatmark () |
8bd58774 MK |
98 | can safely be called from a handler for the |
99 | .B SIGURG | |
100 | signal. | |
847e0d88 | 101 | .PP |
21008754 | 102 | .BR sockatmark () |
c13182ef MK |
103 | is implemented using the |
104 | .B SIOCATMARK | |
fb186734 | 105 | .BR ioctl (2) |
21008754 | 106 | operation. |
21008754 MK |
107 | .SH BUGS |
108 | Prior to glibc 2.4, | |
c13182ef | 109 | .BR sockatmark () |
21008754 MK |
110 | did not work. |
111 | .SH EXAMPLE | |
8bd58774 MK |
112 | The following code can be used after receipt of a |
113 | .B SIGURG | |
114 | signal to read (and discard) all data up to the mark, | |
21008754 | 115 | and then read the byte of data at the mark: |
a2b7a144 MK |
116 | .PP |
117 | .EX | |
21008754 MK |
118 | char buf[BUF_LEN]; |
119 | char oobdata; | |
120 | int atmark, s; | |
121 | ||
122 | for (;;) { | |
c4e7b714 | 123 | atmark = sockatmark(sockfd); |
21008754 MK |
124 | if (atmark == \-1) { |
125 | perror("sockatmark"); | |
126 | break; | |
c13182ef | 127 | } |
7295b7ed | 128 | |
21008754 MK |
129 | if (atmark) |
130 | break; | |
c13182ef | 131 | |
d42ffdf8 | 132 | s = read(sockfd, buf, BUF_LEN); |
29059a65 | 133 | if (s == \-1) |
21008754 | 134 | perror("read"); |
c13182ef | 135 | if (s <= 0) |
21008754 MK |
136 | break; |
137 | } | |
c13182ef | 138 | |
21008754 | 139 | if (atmark == 1) { |
c4e7b714 | 140 | if (recv(sockfd, &oobdata, 1, MSG_OOB) == \-1) { |
21008754 MK |
141 | perror("recv"); |
142 | ... | |
143 | } | |
144 | } | |
a2b7a144 | 145 | .EE |
47297adb | 146 | .SH SEE ALSO |
21008754 MK |
147 | .BR fcntl (2), |
148 | .BR recv (2), | |
149 | .BR send (2), | |
150 | .BR tcp (7) |