Changeset 2181 in subversion


Ignore:
Timestamp:
Dec 18, 2008 2:12:37 PM (4 years ago)
Author:
alec
Message:
  • updated bundled Net_Socket to 1.0.9
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/lib/Net/Socket.php

    r969 r2181  
    124124        $errno = 0; 
    125125        $errstr = ''; 
     126        $old_track_errors = @ini_set('track_errors', 1); 
    126127        if ($options && function_exists('stream_context_create')) { 
    127128            if ($this->timeout) { 
     
    131132            } 
    132133            $context = stream_context_create($options); 
    133             $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); 
     134 
     135            // Since PHP 5 fsockopen doesn't allow context specification 
     136            if (function_exists('stream_socket_client')) { 
     137                $flags = $this->persistent ? STREAM_CLIENT_PERSISTENT : STREAM_CLIENT_CONNECT; 
     138                $addr = $this->addr . ':' . $this->port; 
     139                $fp = stream_socket_client($addr, $errno, $errstr, $timeout, $flags, $context); 
     140            } else { 
     141                $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); 
     142            } 
    134143        } else { 
    135144            if ($this->timeout) { 
     
    141150 
    142151        if (!$fp) { 
     152            if ($errno == 0 && isset($php_errormsg)) { 
     153                $errstr = $php_errormsg; 
     154            } 
     155            @ini_set('track_errors', $old_track_errors); 
    143156            return $this->raiseError($errstr, $errno); 
    144157        } 
    145158 
     159        @ini_set('track_errors', $old_track_errors); 
    146160        $this->fp = $fp; 
    147161 
     
    153167     * 
    154168     * @access public 
    155      * @return mixed true on success or an error object otherwise 
     169     * @return mixed true on success or a PEAR_Error instance otherwise 
    156170     */ 
    157171    function disconnect() 
     
    185199     * @param boolean $mode  True for blocking sockets, false for nonblocking. 
    186200     * @access public 
    187      * @return mixed true on success or an error object otherwise 
     201     * @return mixed true on success or a PEAR_Error instance otherwise 
    188202     */ 
    189203    function setBlocking($mode) 
     
    205219     * @param integer $microseconds  Microseconds. 
    206220     * @access public 
    207      * @return mixed true on success or an error object otherwise 
     221     * @return mixed true on success or a PEAR_Error instance otherwise 
    208222     */ 
    209223    function setTimeout($seconds, $microseconds) 
     
    230244        } 
    231245 
    232         $returned = stream_set_write_buffer($this->fp, $code); 
     246        $returned = stream_set_write_buffer($this->fp, $size); 
    233247        if ($returned == 0) { 
    234248            return true; 
     
    249263     * 
    250264     * @access public 
    251      * @return mixed Array containing information about existing socket resource or an error object otherwise 
     265     * @return mixed Array containing information about existing socket resource or a PEAR_Error instance otherwise 
    252266     */ 
    253267    function getStatus() 
     
    304318     * 
    305319     * @access public 
    306      * @return mixed true on success or an error object otherwise 
     320     * @return mixed If the socket is not connected, returns an instance of PEAR_Error 
     321     *               If the write succeeds, returns the number of bytes written 
     322     *               If the write fails, returns false. 
    307323     */ 
    308324    function write($data, $blocksize = null) 
     
    313329 
    314330        if (is_null($blocksize) && !OS_WINDOWS) { 
    315             return fwrite($this->fp, $data); 
     331            return @fwrite($this->fp, $data); 
    316332        } else { 
    317333            if (is_null($blocksize)) { 
     
    433449 
    434450    /** 
    435      * Reads an IP Address and returns it in a dot formated string 
    436      * 
    437      * @access public 
    438      * @return Dot formated string, or a PEAR_Error if 
     451     * Reads an IP Address and returns it in a dot formatted string 
     452     * 
     453     * @access public 
     454     * @return Dot formatted string, or a PEAR_Error if 
    439455     *         not connected. 
    440456     */ 
     
    446462 
    447463        $buf = @fread($this->fp, 4); 
    448         return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]), 
     464        return sprintf('%d.%d.%d.%d', ord($buf[0]), ord($buf[1]), 
    449465                       ord($buf[2]), ord($buf[3])); 
    450466    } 
Note: See TracChangeset for help on using the changeset viewer.