Index: branches/version-2_13_0/data/module/Net/Socket.php
===================================================================
--- branches/version-2_13_0/data/module/Net/Socket.php	(revision 23126)
+++ branches/version-2_13_0/data/module/Net/Socket.php	(revision 23143)
@@ -5,5 +5,5 @@
  * PHP Version 4
  *
- * Copyright (c) 1997-2013 The PHP Group
+ * Copyright (c) 1997-2003 The PHP Group
  *
  * This source file is subject to version 2.0 of the PHP license,
@@ -24,4 +24,5 @@
  * @copyright 1997-2003 The PHP Group
  * @license   http://www.php.net/license/2_02.txt PHP 2.02
+ * @version   CVS: $Id$
  * @link      http://pear.php.net/packages/Net_Socket
  */
@@ -77,9 +78,9 @@
 
     /**
-     * Number of seconds to wait on socket operations before assuming
+     * Number of seconds to wait on socket connections before assuming
      * there's no more data. Defaults to no timeout.
-     * @var integer|float $timeout
-     */
-    var $timeout = null;
+     * @var integer $timeout
+     */
+    var $timeout = false;
 
     /**
@@ -100,15 +101,15 @@
      * already connected, it disconnects and connects again.
      *
-     * @param string  $addr       IP address or host name (may be with protocol prefix).
+     * @param string  $addr       IP address or host name.
      * @param integer $port       TCP port number.
      * @param boolean $persistent (optional) Whether the connection is
      *                            persistent (kept open between requests
      *                            by the web server).
-     * @param integer $timeout    (optional) Connection socket timeout.
+     * @param integer $timeout    (optional) How long to wait for data.
      * @param array   $options    See options for stream_context_create.
      *
      * @access public
      *
-     * @return boolean|PEAR_Error  True on success or a PEAR_Error on failure.
+     * @return boolean | PEAR_Error  True on success or a PEAR_Error on failure.
      */
     function connect($addr, $port = 0, $persistent = null,
@@ -122,8 +123,9 @@
         if (!$addr) {
             return $this->raiseError('$addr cannot be empty');
-        } else if (strspn($addr, ':.0123456789') == strlen($addr)) {
-            $this->addr = strpos($addr, ':') !== false ? '['.$addr.']' : $addr;
+        } elseif (strspn($addr, '.0123456789') == strlen($addr) ||
+                  strstr($addr, '/') !== false) {
+            $this->addr = $addr;
         } else {
-            $this->addr = $addr;
+            $this->addr = @gethostbyname($addr);
         }
 
@@ -132,4 +134,8 @@
         if ($persistent !== null) {
             $this->persistent = $persistent;
+        }
+
+        if ($timeout !== null) {
+            $this->timeout = $timeout;
         }
 
@@ -140,9 +146,10 @@
         $old_track_errors = @ini_set('track_errors', 1);
 
-        if ($timeout <= 0) {
-            $timeout = @ini_get('default_socket_timeout');
-        }
-
         if ($options && function_exists('stream_context_create')) {
+            if ($this->timeout) {
+                $timeout = $this->timeout;
+            } else {
+                $timeout = 0;
+            }
             $context = stream_context_create($options);
 
@@ -163,5 +170,10 @@
             }
         } else {
-            $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout);
+            if ($this->timeout) {
+                $fp = @$openfunc($this->addr, $this->port, $errno,
+                                 $errstr, $this->timeout);
+            } else {
+                $fp = @$openfunc($this->addr, $this->port, $errno, $errstr);
+            }
         }
 
@@ -176,5 +188,5 @@
         @ini_set('track_errors', $old_track_errors);
         $this->fp = $fp;
-        $this->setTimeout();
+
         return $this->setBlocking($this->blocking);
     }
@@ -247,29 +259,16 @@
      *
      * @param integer $seconds      Seconds.
-     * @param integer $microseconds Microseconds, optional.
-     *
-     * @access public
-     * @return mixed True on success or false on failure or
-     *               a PEAR_Error instance when not connected
-     */
-    function setTimeout($seconds = null, $microseconds = null)
-    {
-        if (!is_resource($this->fp)) {
-            return $this->raiseError('not connected');
-        }
-
-        if ($seconds === null && $microseconds === null) {
-            $seconds      = (int) $this->timeout;
-            $microseconds = (int) (($this->timeout - $seconds) * 1000000);
-        } else {
-            $this->timeout = $seconds + $microseconds/1000000;
-        }
-
-        if ($this->timeout > 0) {
-            return stream_set_timeout($this->fp, (int) $seconds, (int) $microseconds);
-        }
-        else {
-            return false;
-        }
+     * @param integer $microseconds Microseconds.
+     *
+     * @access public
+     * @return mixed true on success or a PEAR_Error instance otherwise
+     */
+    function setTimeout($seconds, $microseconds)
+    {
+        if (!is_resource($this->fp)) {
+            return $this->raiseError('not connected');
+        }
+
+        return socket_set_timeout($this->fp, $seconds, $microseconds);
     }
 
@@ -317,5 +316,5 @@
         }
 
-        return stream_get_meta_data($this->fp);
+        return socket_get_status($this->fp);
     }
 
@@ -323,12 +322,9 @@
      * Get a specified line of data
      *
-     * @param int $size Reading ends when size - 1 bytes have been read,
-     *                  or a newline or an EOF (whichever comes first).
-     *                  If no size is specified, it will keep reading from
-     *                  the stream until it reaches the end of the line.
-     *
-     * @access public
-     * @return mixed $size bytes of data from the socket, or a PEAR_Error if
-     *         not connected. If an error occurs, FALSE is returned.
+     * @param int $size ??
+     *
+     * @access public
+     * @return $size bytes of data from the socket, or a PEAR_Error if
+     *         not connected.
      */
     function gets($size = null)
@@ -375,8 +371,7 @@
      * @access public
      * @return mixed If the socket is not connected, returns an instance of
-     *               PEAR_Error.
-     *               If the write succeeds, returns the number of bytes written.
+     *               PEAR_Error
+     *               If the write succeeds, returns the number of bytes written
      *               If the write fails, returns false.
-     *               If the socket times out, returns an instance of PEAR_Error.
      */
     function write($data, $blocksize = null)
@@ -387,20 +382,5 @@
 
         if (is_null($blocksize) && !OS_WINDOWS) {
-            $written = @fwrite($this->fp, $data);
-
-            // Check for timeout or lost connection
-            if (!$written) {
-                $meta_data = $this->getStatus();
-
-                if (!is_array($meta_data)) {
-                    return $meta_data; // PEAR_Error
-                }
-
-                if (!empty($meta_data['timed_out'])) {
-                    return $this->raiseError('timed out');
-                }
-            }
-
-            return $written;
+            return @fwrite($this->fp, $data);
         } else {
             if (is_null($blocksize)) {
@@ -412,20 +392,7 @@
             while ($pos < $size) {
                 $written = @fwrite($this->fp, substr($data, $pos, $blocksize));
-
-                // Check for timeout or lost connection
                 if (!$written) {
-                    $meta_data = $this->getStatus();
-
-                    if (!is_array($meta_data)) {
-                        return $meta_data; // PEAR_Error
-                    }
-
-                    if (!empty($meta_data['timed_out'])) {
-                        return $this->raiseError('timed out');
-                    }
-
                     return $written;
                 }
-
                 $pos += $written;
             }
@@ -441,5 +408,5 @@
      *
      * @access public
-     * @return mixed fwrite() result, or PEAR_Error when not connected
+     * @return mixed fputs result, or an error
      */
     function writeLine($data)
