public function write($buffer, $length = null)
    {
        if (null === $length) {
            $length = strlen($buffer);
        }

        // make sure everything is written
        do {
            $return = @socket_write($this->resource, $buffer, $length);

            if (false !== $return && $return < $length) {
                $buffer = substr($buffer, $return);
                $length -= $return;
            } else {
                break;
            }
        } while (true);

        if ($return === false) {
            throw new SocketException($this->resource);
        }

        return $return;
    }
public function write($buffer, $length = null)
    {
        if (null === $length) {
            $length = strlen($buffer);
        }

        // make sure everything is written
        do {
            $return = @socket_write($this->resource, $buffer, $length);

            if (false !== $return && $return < $length) {
                $buffer = substr($buffer, $return);
                $length -= $return;
            } else {
                break;
            }
        } while (true);

        if ($return === false) {
            throw new SocketException($this->resource);
        }

        return $return;
    }
public function write ( $ buffer , $ length = null ) { if ( null === $ length ) { $ length = strlen ( $ buffer ) ; } // make sure everything is written do { $ return = @ socket_write ( $ this -> resource , $ buffer , $ length ) ; if ( false !== $ return && $ return < $ length ) { $ buffer = substr ( $ buffer , $ return ) ; $ length -= $ return ; } else { break ; } } while ( true ) ; if ( $ return === false ) { throw new SocketException ( $ this -> resource ) ; } return $ return ; }
Write to a socket.

<p>The function <code>write()</code> writes to the socket from the given buffer.</p>

@param string $buffer The buffer to be written.
@param int    $length The optional parameter length can specify an alternate length of bytes written to the socket.
If this length is greater than the buffer length, it is silently truncated to the length of the buffer.

@throws Exception\SocketException If there was a failure.

@return int Returns the number of bytes successfully written to the socket.
Write to a socket .