mirror of https://github.com/mkerrisk/man-pages
New page.
This commit is contained in:
parent
84564be219
commit
21008754d7
|
@ -0,0 +1,118 @@
|
|||
.\" Copyright (c) 2006, Michael Kerrisk (mtk-manpages@gmx.net)
|
||||
.\"
|
||||
.\" Permission is granted to make and distribute verbatim copies of this
|
||||
.\" manual provided the copyright notice and this permission notice are
|
||||
.\" preserved on all copies.
|
||||
.\"
|
||||
.\" Permission is granted to copy and distribute modified versions of this
|
||||
.\" manual under the conditions for verbatim copying, provided that the
|
||||
.\" entire resulting derived work is distributed under the terms of a
|
||||
.\" permission notice identical to this one.
|
||||
.\"
|
||||
.\" Since the Linux kernel and libraries are constantly changing, this
|
||||
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
||||
.\" responsibility for errors or omissions, or for damages resulting from
|
||||
.\" the use of the information contained herein.
|
||||
.\"
|
||||
.\" Formatted or processed versions of this manual, if unaccompanied by
|
||||
.\" the source, must acknowledge the copyright and authors of this work.
|
||||
.\"
|
||||
.TH SOCKATMARK 3 2006-04-24 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
sockatmark \- determine whether socket is at out-of-band mark
|
||||
.SH SYNOPSIS
|
||||
.B #include <sys/socket.h>
|
||||
.sp
|
||||
.BI "int sockatmark(int " fd );
|
||||
.SH DESCRIPTION
|
||||
.BR sockatmark ()
|
||||
returns a value indicating whether or not the socket referred
|
||||
to by the file descriptor
|
||||
.I fd
|
||||
is at the out-of-band mark.
|
||||
If the socket is at the mark, then 1 is returned;
|
||||
if the socket is not at the mark, 0 is returned.
|
||||
This function does not remove the out-of-band mark.
|
||||
.SH "RETURN VALUE"
|
||||
A successful call to
|
||||
.BR sockatmark ()
|
||||
returns 1 if the socket is at the out-of-band mark, or 0 if it is not.
|
||||
On error, \-1 is returned and \fIerrno\fP is set to indicate the error.
|
||||
.SH ERRORS
|
||||
.TP
|
||||
.B EBADF
|
||||
.I fd
|
||||
is not a valid file descriptor.
|
||||
.TP
|
||||
.B EINVAL
|
||||
.\" POSIX.1 says ENOTTY for this case
|
||||
.I fd
|
||||
is not a file descriptor to which
|
||||
.BR sockatmark ()
|
||||
can be applied.
|
||||
.SH NOTES
|
||||
If
|
||||
.BR sockatmark ()
|
||||
returns 1, then the out-of-band data can be read using the
|
||||
.B MSG_OOB
|
||||
flag of
|
||||
.BR recv (2).
|
||||
|
||||
Out-of-band data is only supported on some stream socket protocols.
|
||||
|
||||
.BR sockatmark ()
|
||||
can safely be called from a handler for the SIGURG signal.
|
||||
|
||||
.BR sockatmark ()
|
||||
is implemented using the
|
||||
.B SIOCATMARK
|
||||
.BR ioctl ()
|
||||
operation.
|
||||
.SH "CONFORMING TO"
|
||||
POSIX.1-2001
|
||||
.SH VERSIONS
|
||||
.BR sockatmark ()
|
||||
was added to glibc in version 2.2.4.
|
||||
.SH BUGS
|
||||
Prior to glibc 2.4,
|
||||
.BR sockatmark ()
|
||||
did not work.
|
||||
.SH EXAMPLE
|
||||
The following code can be used after receipt of a SIGURG signal
|
||||
to read (and discard) all data up to the mark,
|
||||
and then read the byte of data at the mark:
|
||||
.nf
|
||||
|
||||
char buf[BUF_LEN];
|
||||
char oobdata;
|
||||
int atmark, s;
|
||||
|
||||
for (;;) {
|
||||
atmark = sockatmark(fd);
|
||||
if (atmark == \-1) {
|
||||
perror("sockatmark");
|
||||
break;
|
||||
}
|
||||
|
||||
if (atmark)
|
||||
break;
|
||||
|
||||
s = read(fd, buf, BUF_LEN) <= 0);
|
||||
if (s == -1)
|
||||
perror("read");
|
||||
if (s <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (atmark == 1) {
|
||||
if (recv(fd, &oobdata, 1, MSG_OOB) == \-1) {
|
||||
perror("recv");
|
||||
...
|
||||
}
|
||||
}
|
||||
.fi
|
||||
.SH "SEE ALSO"
|
||||
.BR fcntl (2),
|
||||
.BR recv (2),
|
||||
.BR send (2),
|
||||
.BR tcp (7)
|
Loading…
Reference in New Issue