]> git.proxmox.com Git - systemd.git/blame - man/sd_is_socket_inet.html
Imported Upstream version 214
[systemd.git] / man / sd_is_socket_inet.html
CommitLineData
663996b3
MS
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_is_fifo</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
2 a.headerlink {
3 color: #c60f0f;
4 font-size: 0.8em;
5 padding: 0 4px 0 4px;
6 text-decoration: none;
7 visibility: hidden;
8 }
9
10 a.headerlink:hover {
11 background-color: #c60f0f;
12 color: white;
13 }
14
15 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
16 visibility: visible;
17 }
18 </style><a href="index.html">Index </a>·
19 <a href="systemd.directives.html">Directives </a>·
20 <a href="../python-systemd/index.html">Python </a>·
21 <a href="../libudev/index.html">libudev </a>·
60f067b4 22 <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 214</span><hr><div class="refentry"><a name="sd_is_fifo"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_is_fifo, sd_is_socket, sd_is_socket_inet, sd_is_socket_unix, sd_is_mq, sd_is_special — Check the type of a file descriptor</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-daemon.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_fifo</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_socket</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">family</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">type</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">listening</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_socket_inet</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">family</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">type</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">listening</var>, </td></tr><tr><td> </td><td>uint16_t <var class="pdparam">port</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_socket_unix</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">type</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">listening</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">length</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_mq</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_special</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm214197320368"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_is_fifo()</code> may be called
663996b3
MS
23 to check whether the specified file descriptor refers
24 to a FIFO or pipe. If the <em class="parameter"><code>path</code></em>
14228c0d
MB
25 parameter is not <code class="constant">NULL</code>, it is
26 checked whether the FIFO is bound to the specified
27 file system path.</p><p><code class="function">sd_is_socket()</code> may be
663996b3
MS
28 called to check whether the specified file descriptor
29 refers to a socket. If the
30 <em class="parameter"><code>family</code></em> parameter is not
14228c0d
MB
31 <code class="constant">AF_UNSPEC</code>, it is checked whether
32 the socket is of the specified family (AF_UNIX,
33 <code class="constant">AF_INET</code>, ...). If the
34 <em class="parameter"><code>type</code></em> parameter is not 0, it is
663996b3 35 checked whether the socket is of the specified type
14228c0d
MB
36 (<code class="constant">SOCK_STREAM</code>,
37 <code class="constant">SOCK_DGRAM</code>, ...). If the
38 <em class="parameter"><code>listening</code></em> parameter is positive,
663996b3
MS
39 it is checked whether the socket is in accepting mode,
40 i.e. <code class="function">listen()</code> has been called for
41 it. If <em class="parameter"><code>listening</code></em> is 0, it is
42 checked whether the socket is not in this mode. If the
43 parameter is negative, no such check is made. The
44 <em class="parameter"><code>listening</code></em> parameter should only
45 be used for stream sockets and should be set to a
46 negative value otherwise.</p><p><code class="function">sd_is_socket_inet()</code> is
47 similar to <code class="function">sd_is_socket()</code>, but
48 optionally checks the IPv4 or IPv6 port number the
49 socket is bound to, unless <em class="parameter"><code>port</code></em>
50 is zero. For this call <em class="parameter"><code>family</code></em>
14228c0d
MB
51 must be passed as either <code class="constant">AF_UNSPEC</code>, <code class="constant">AF_INET</code>, or
52 <code class="constant">AF_INET6</code>.</p><p><code class="function">sd_is_socket_unix()</code> is
53 similar to <code class="function">sd_is_socket()</code> but
54 optionally checks the <code class="constant">AF_UNIX</code> path the socket is bound
663996b3 55 to, unless the <em class="parameter"><code>path</code></em> parameter
14228c0d
MB
56 is <code class="constant">NULL</code>. For normal file system <code class="constant">AF_UNIX</code> sockets,
57 set the <em class="parameter"><code>length</code></em> parameter to 0. For
58 Linux abstract namespace sockets, set the
663996b3 59 <em class="parameter"><code>length</code></em> to the size of the
14228c0d 60 address, including the initial 0 byte, and set the
663996b3
MS
61 <em class="parameter"><code>path</code></em> to the initial 0 byte of
62 the socket address.</p><p><code class="function">sd_is_mq()</code> may be called to
63 check whether the specified file descriptor refers to
64 a POSIX message queue. If the
14228c0d
MB
65 <em class="parameter"><code>path</code></em> parameter is not
66 <code class="constant">NULL</code>, it is checked whether the
60f067b4
JS
67 message queue is bound to the specified name.</p><p><code class="function">sd_is_special()</code> may be
68 called to check whether the specified file descriptor
69 refers to a special file. If the
70 <em class="parameter"><code>path</code></em> parameter is not
71 <code class="constant">NULL</code>, it is checked whether the file
72 descriptor is bound to the specified file
73 name. Special files in this context are character
74 device nodes and files in <code class="filename">/proc</code>
75 or <code class="filename">/sys</code>.</p></div><div class="refsect1"><a name="idm214192317264"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On failure, these calls return a negative
663996b3 76 errno-style error code. If the file descriptor is of
14228c0d 77 the specified type and bound to the specified address,
663996b3 78 a positive return value is returned, otherwise
60f067b4
JS
79 zero.</p></div><div class="refsect1"><a name="idm214192315824"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p><a name="pkgconfig-text"></a>These APIs are implemented as a shared
80 library, which can be compiled and linked to with the
81 <code class="constant">libsystemd</code> <a href="pkg-config.html"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
82 file.</p><p>Internally, these function use a combination of
663996b3
MS
83 <code class="filename">fstat()</code> and
84 <code class="filename">getsockname()</code> to check the file
60f067b4 85 descriptor type and where it is bound to.</p></div><div class="refsect1"><a name="idm214192312688"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
663996b3
MS
86 <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
87 <a href="sd-daemon.html"><span class="citerefentry"><span class="refentrytitle">sd-daemon</span>(3)</span></a>,
88 <a href="sd_listen_fds.html"><span class="citerefentry"><span class="refentrytitle">sd_listen_fds</span>(3)</span></a>,
89 <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
90 <a href="systemd.socket.html"><span class="citerefentry"><span class="refentrytitle">systemd.socket</span>(5)</span></a>
91 </p></div></div></body></html>