157 lines
6.1 KiB
HTML
157 lines
6.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>sockatmark</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
|
|
<basefont size="3"> <a name="sockatmark"></a> <a name="tag_03_707"></a><!-- sockatmark -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_707_01"></a>NAME</h4>
|
|
|
|
<blockquote>sockatmark - determine whether a socket is at the out-of-band mark</blockquote>
|
|
|
|
<h4><a name="tag_03_707_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>#include <<a href="../basedefs/sys/socket.h.html">sys/socket.h</a>><br>
|
|
<br>
|
|
int sockatmark(int</tt> <i>s</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>sockatmark</i>() function shall determine whether the socket specified by the descriptor <i>s</i> is at the out-of-band
|
|
data mark (see the System Interfaces volume of IEEE Std 1003.1-2001, <a href=
|
|
"../functions/xsh_chap02_10.html#tag_02_10_12">Section 2.10.12, Socket Out-of-Band State</a>). If the protocol for the socket
|
|
supports out-of-band data by marking the stream with an out-of-band data mark, the <i>sockatmark</i>() function shall return 1 when
|
|
all data preceding the mark has been read and the out-of-band data mark is the first element in the receive queue. The
|
|
<i>sockatmark</i>() function shall not remove the mark from the stream.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, the <i>sockatmark</i>() function shall return a value indicating whether the socket is at an
|
|
out-of-band data mark. If the protocol has marked the data stream and all data preceding the mark has been read, the return value
|
|
shall be 1; if there is no mark, or if data precedes the mark in the receive queue, the <i>sockatmark</i>() function shall return
|
|
0. Otherwise, it shall return a value of -1 and set <i>errno</i> to indicate the error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>sockatmark</i>() function shall fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EBADF]</dt>
|
|
|
|
<dd>The <i>s</i> argument is not a valid file descriptor.</dd>
|
|
|
|
<dt>[ENOTTY]</dt>
|
|
|
|
<dd>The <i>s</i> argument does not specify a descriptor for a socket.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_707_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The use of this function between receive operations allows an application to determine which received data precedes the
|
|
out-of-band data and which follows the out-of-band data.</p>
|
|
|
|
<p>There is an inherent race condition in the use of this function. On an empty receive queue, the current read of the location
|
|
might well be at the "mark", but the system has no way of knowing that the next data segment that will arrive from the network
|
|
will carry the mark, and <i>sockatmark</i>() will return false, and the next read operation will silently consume the mark.</p>
|
|
|
|
<p>Hence, this function can only be used reliably when the application already knows that the out-of-band data has been seen by the
|
|
system or that it is known that there is data waiting to be read at the socket (via SIGURG or <a href=
|
|
"../functions/select.html"><i>select</i>()</a>). See <a href="xsh_chap02_10.html#tag_02_10_11"><i>Socket Receive Queue</i></a> , <a
|
|
href="xsh_chap02_10.html#tag_02_10_12"><i>Socket Out-of-Band Data State</i></a> , <a href=
|
|
"xsh_chap02_10.html#tag_02_10_14"><i>Signals</i></a> , and <a href="../functions/pselect.html"><i>pselect</i>()</a> for
|
|
details.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>sockatmark</i>() function replaces the historical SIOCATMARK command to <a href=
|
|
"../functions/ioctl.html"><i>ioctl</i>()</a> which implemented the same functionality on many implementations. Using a wrapper
|
|
function follows the adopted conventions to avoid specifying commands to the <a href="../functions/ioctl.html"><i>ioctl</i>()</a>
|
|
function, other than those now included to support XSI STREAMS. The <i>sockatmark</i>() function could be implemented as
|
|
follows:</p>
|
|
|
|
<pre>
|
|
<tt>#include <sys/ioctl.h>
|
|
<br>
|
|
int sockatmark(int s)
|
|
{
|
|
int val;
|
|
if (ioctl(s,SIOCATMARK,&val)==-1)
|
|
return(-1);
|
|
return(val);
|
|
}
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The use of [ENOTTY] to indicate an incorrect descriptor type matches the historical behavior of SIOCATMARK.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="pselect.html"><i>pselect</i>()</a> , <a href="recv.html"><i>recv</i>()</a> , <a href=
|
|
"recvmsg.html"><i>recvmsg</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/sys/socket.h.html"><i><sys/socket.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_707_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 6. Derived from IEEE Std 1003.1g-2000.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|