Changeset e275ce6 in github
- Timestamp:
- Dec 18, 2008 2:12:37 PM (4 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- e943e1a
- Parents:
- d78c417
- File:
-
- 1 edited
-
program/lib/Net/Socket.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/Net/Socket.php
ra5b5982 re275ce6 124 124 $errno = 0; 125 125 $errstr = ''; 126 $old_track_errors = @ini_set('track_errors', 1); 126 127 if ($options && function_exists('stream_context_create')) { 127 128 if ($this->timeout) { … … 131 132 } 132 133 $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 } 134 143 } else { 135 144 if ($this->timeout) { … … 141 150 142 151 if (!$fp) { 152 if ($errno == 0 && isset($php_errormsg)) { 153 $errstr = $php_errormsg; 154 } 155 @ini_set('track_errors', $old_track_errors); 143 156 return $this->raiseError($errstr, $errno); 144 157 } 145 158 159 @ini_set('track_errors', $old_track_errors); 146 160 $this->fp = $fp; 147 161 … … 153 167 * 154 168 * @access public 155 * @return mixed true on success or a n error objectotherwise169 * @return mixed true on success or a PEAR_Error instance otherwise 156 170 */ 157 171 function disconnect() … … 185 199 * @param boolean $mode True for blocking sockets, false for nonblocking. 186 200 * @access public 187 * @return mixed true on success or a n error objectotherwise201 * @return mixed true on success or a PEAR_Error instance otherwise 188 202 */ 189 203 function setBlocking($mode) … … 205 219 * @param integer $microseconds Microseconds. 206 220 * @access public 207 * @return mixed true on success or a n error objectotherwise221 * @return mixed true on success or a PEAR_Error instance otherwise 208 222 */ 209 223 function setTimeout($seconds, $microseconds) … … 230 244 } 231 245 232 $returned = stream_set_write_buffer($this->fp, $ code);246 $returned = stream_set_write_buffer($this->fp, $size); 233 247 if ($returned == 0) { 234 248 return true; … … 249 263 * 250 264 * @access public 251 * @return mixed Array containing information about existing socket resource or a n error objectotherwise265 * @return mixed Array containing information about existing socket resource or a PEAR_Error instance otherwise 252 266 */ 253 267 function getStatus() … … 304 318 * 305 319 * @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. 307 323 */ 308 324 function write($data, $blocksize = null) … … 313 329 314 330 if (is_null($blocksize) && !OS_WINDOWS) { 315 return fwrite($this->fp, $data);331 return @fwrite($this->fp, $data); 316 332 } else { 317 333 if (is_null($blocksize)) { … … 433 449 434 450 /** 435 * Reads an IP Address and returns it in a dot format ed string436 * 437 * @access public 438 * @return Dot format ed string, or a PEAR_Error if451 * 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 439 455 * not connected. 440 456 */ … … 446 462 447 463 $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]), 449 465 ord($buf[2]), ord($buf[3])); 450 466 }
Note: See TracChangeset
for help on using the changeset viewer.
