mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
110 lines
4.9 KiB
HTML
110 lines
4.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>开启一个套接字连接</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.socket-connect" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">socket_connect</h1>
|
||
<p class="verinfo">(PHP 4 >= 4.1.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">socket_connect</span> — <span class="dc-title">开启一个套接字连接</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.socket-connect-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>socket_connect</strong></span>
|
||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$socket</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$address</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 0</span></span>
|
||
] ) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
用 <span class="function"><a href="socket_create.html" class="function">socket_create()</a></span> 创建的有效的套接字资源来连接到 <code class="parameter">address</code> 。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.socket-connect-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">socket</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">address</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
如果参数 <code class="parameter">socket</code> 是 <strong><code>AF_INET</code></strong> ,
|
||
那么参数 <code class="parameter">address</code> 则可以是一个点分四组表示法(例如 <em>127.0.0.1</em> ) 的 IPv4 地址;
|
||
如果支持 IPv6 并且 <code class="parameter">socket</code> 是 <strong><code>AF_INET6</code></strong>,那么 <code class="parameter">address</code>
|
||
也可以是有效的 IPv6 地址(例如 <em>::1</em>);如果套接字类型为 <strong><code>AF_UNIX</code></strong> ,那么
|
||
<code class="parameter">address</code> 也可以是一个Unix 套接字。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">port</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
参数 <code class="parameter">port</code> 仅仅用于 <strong><code>AF_INET</code></strong> 和 <strong><code>AF_INET6</code></strong>
|
||
套接字连接的时候,并且是在此情况下是需要强制说明连接对应的远程服务器上的端口号。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.socket-connect-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。 错误代码会传入 <span class="function"><a href="socket_last_error.html" class="function">socket_last_error()</a></span> ,如果将此参数传入 <span class="function"><a href="socket_strerror.html" class="function">socket_strerror()</a></span>
|
||
则可以得到错误的文字说明。
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
If the socket is non-blocking then this function returns <strong><code>FALSE</code></strong> with an
|
||
error <em>Operation now in progress</em>.
|
||
</p>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.socket-connect-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="socket_bind.html" class="function" rel="rdfs-seeAlso">socket_bind()</a> - 给套接字绑定名字</span></li>
|
||
<li class="member"><span class="function"><a href="socket_listen.html" class="function" rel="rdfs-seeAlso">socket_listen()</a> - Listens for a connection on a socket</span></li>
|
||
<li class="member"><span class="function"><a href="socket_create.html" class="function" rel="rdfs-seeAlso">socket_create()</a> - 创建一个套接字(通讯节点)</span></li>
|
||
<li class="member"><span class="function"><a href="socket_last_error.html" class="function" rel="rdfs-seeAlso">socket_last_error()</a> - Returns the last error on the socket</span></li>
|
||
<li class="member"><span class="function"><a href="socket_strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Return a string describing a socket error</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |