Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 4388

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>socket_write</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="Socket Functions"
HREF="ref.sockets.html"><LINK
REL="PREVIOUS"
TITLE="socket_strerror"
HREF="function.socket-strerror.html"><LINK
REL="NEXT"
TITLE="Standard PHP Library (SPL) Functions"
HREF="ref.spl.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.socket-strerror.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ref.spl.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.socket-write"
></A
>socket_write</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN213881"
></A
><P
>    (PHP 4 &#62;= 4.1.0, PHP 5)</P
>socket_write&nbsp;--&nbsp;Write to a socket</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN213884"
></A
><H2
>Description</H2
>int <B
CLASS="methodname"
>socket_write</B
> ( resource socket, string buffer [, int length] )<BR
></BR
><P
>&#13;     The function <B
CLASS="function"
>socket_write()</B
> writes to the socket 
     <CODE
CLASS="parameter"
>socket</CODE
> from
     <CODE
CLASS="parameter"
>buffer</CODE
>.
    </P
><P
>&#13;     The optional parameter <CODE
CLASS="parameter"
>length</CODE
> can specify an
     alternate length of bytes written to the socket. If this length is
     greater then the buffer length, it is silently truncated to the length of
     the buffer.
    </P
><P
>&#13;     Returns the number of bytes successfully written to the socket or <TT
CLASS="constant"
><B
>FALSE</B
></TT
>
     one error. The error code can be retrieved with
     <A
HREF="function.socket-last-error.html"
><B
CLASS="function"
>socket_last_error()</B
></A
>. This code may be passed to
     <A
HREF="function.socket-strerror.html"
><B
CLASS="function"
>socket_strerror()</B
></A
> to get a textual explanation of the
     error.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      <B
CLASS="function"
>socket_write()</B
> does not necessarily write all bytes
      from the given buffer. It's valid that, depending on the network
      buffers etc., only a certain amount of data, even one byte, is written
      though your buffer is greater. You have to watch out so you don't
      unintentionally forget to transmit the rest of your data.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      It is perfectly valid for <B
CLASS="function"
>socket_write()</B
> to
      return zero which means no bytes have been written. Be sure to use the
      <TT
CLASS="literal"
>===</TT
> operator to check for <TT
CLASS="constant"
><B
>FALSE</B
></TT
> in case of an
      error.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also 
     <A
HREF="function.socket-accept.html"
><B
CLASS="function"
>socket_accept()</B
></A
>,
     <A
HREF="function.socket-bind.html"
><B
CLASS="function"
>socket_bind()</B
></A
>,
     <A
HREF="function.socket-connect.html"
><B
CLASS="function"
>socket_connect()</B
></A
>,
     <A
HREF="function.socket-listen.html"
><B
CLASS="function"
>socket_listen()</B
></A
>,
     <A
HREF="function.socket-read.html"
><B
CLASS="function"
>socket_read()</B
></A
> and
     <A
HREF="function.socket-strerror.html"
><B
CLASS="function"
>socket_strerror()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.socket-strerror.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="ref.spl.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>socket_strerror</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sockets.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Standard PHP Library (SPL) Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>