diff --git a/src/Lunr/Network/StreamSocket.php b/src/Lunr/Network/StreamSocket.php
new file mode 100644
index 0000000000000000000000000000000000000000..e35908b5dc7ffc82614811121b58582d21ea326c
--- /dev/null
+++ b/src/Lunr/Network/StreamSocket.php
@@ -0,0 +1,420 @@
+<?php
+
+/**
+ * This file contains an abstract stream socket wrapper class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Libraries
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network;
+
+/**
+ * abstract stream socket wrapper class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Libraries
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ */
+abstract class StreamSocket
+{
+    /**
+     * Stream socket context options array
+     * @var array
+     */
+    protected $context_options;
+
+    /**
+     * Stream socket context
+     * @var resource
+     */
+    protected $context;
+
+    /**
+     * Stream socket resource handle
+     * @var resource
+     */
+    protected $handle;
+
+    /**
+     * Informations about the request
+     * @var array
+     */
+    protected $meta_data;
+
+    /**
+     * Stream socket error number
+     * @var Integer
+     */
+    protected $errno;
+
+    /**
+     * Stream socket error message
+     * @var String
+     */
+    protected $errmsg;
+
+    /**
+     * Blocking mode of the stream
+     * @var Boolean
+     */
+    protected $blocking;
+
+    /**
+     * Notification callback function name
+     * @var String
+     */
+    protected $notification;
+
+    /**
+     * flag values for the stream creation
+     * @var array
+     */
+    protected $flags;
+
+    /**
+     * Time out for read/write transactions in seconds.
+     * @var Integer
+     */
+    protected $timeout_seconds;
+
+    /**
+     * Time out for read/write transactions in microseconds.
+     * @var Integer
+     */
+    protected $timeout_microseconds;
+
+    /**
+     * Conctructor.
+     */
+    public function __construct()
+    {
+        $this->context_options = array();
+
+        // default: no error
+        $this->errno  = 0;
+        $this->errmsg = '';
+
+        // default no callback function
+        $this->notification = '';
+
+        // default: no meta_data
+        $this->meta_data = array();
+        // flags are empty as from abstract class
+        $this->flags = array();
+
+        // pre-initialization
+        $this->handle  = NULL;
+        $this->context = NULL;
+
+        // default blocking stream
+        $this->blocking = TRUE;
+
+        // default stream timeout
+        $this->timeout_seconds      = 60;
+        $this->timeout_microseconds = 0;
+    }
+
+    /**
+     * Destructor.
+     */
+    public function __destruct()
+    {
+        if(is_resource($this->handle))
+        {
+            fclose($this->handle);
+        }
+
+        unset($this->context_options);
+        unset($this->meta_data);
+        unset($this->errno);
+        unset($this->errmsg);
+        unset($this->blocking);
+        unset($this->notification);
+        unset($this->flag);
+        unset($this->timeout_seconds);
+        unset($this->timeout_microseconds);
+        unset($this->handle);
+        unset($this->context);
+    }
+
+    /**
+     * Get access to certain private attributes.
+     *
+     * This gives access to errno, errmsg and meta_data.
+     *
+     * @param String $name Attribute name
+     *
+     * @return mixed $return Value of the chosen attribute
+     */
+    public function __get($name)
+    {
+        switch ($name)
+        {
+            case 'meta_data':
+            case 'errno':
+            case 'errmsg':
+                return $this->{$name};
+            default:
+                return NULL;
+        }
+    }
+
+    /**
+     * Set an option for the stream stream context in the given wrapper.
+     *
+     * @param String $wrapper The wrapper of the option.
+     * @param String $option  The option name
+     * @param mixed  $value   The value of the option
+     *
+     * @return StreamSocket $self Self-reference
+     */
+    public function set_context_option($wrapper, $option, $value)
+    {
+        if(! is_string($wrapper))
+        {
+            return $this;
+        }
+
+        if(! in_array($wrapper, stream_get_wrappers() ) &&
+           ! in_array($wrapper, stream_get_transports()))
+        {
+            return $this;
+        }
+
+        if(! array_key_exists($wrapper, $this->context_options))
+        {
+            $this->context_options[$wrapper] = array();
+        }
+
+        $this->context_options[$wrapper][$option] = $value;
+
+        return $this;
+    }
+
+    /**
+     * Set the options for the stream stream context.
+     *
+     * @param array $options The options array
+     *
+     * @return StreamSocket $self Self-reference
+     */
+    public function set_context_options($options)
+    {
+        if(! is_array($options))
+        {
+            return $this;
+        }
+
+        foreach($options as $wrapper => $pair)
+        {
+            foreach($pair as $option => $value)
+            {
+                $this->set_context_option($wrapper, $option, $value);
+            }
+        }
+
+        return $this;
+    }
+
+    /**
+     * Set the blocking mode for the stream.
+     *
+     * @param Boolean $blocking Wether the stream is set to blocking mode or not
+     *
+     * @return StreamSocket $self Self-reference
+     */
+    public function set_blocking($blocking)
+    {
+        if(is_bool($blocking))
+        {
+            $this->blocking = $blocking;
+        }
+
+        return $this;
+    }
+
+    /**
+     * Set the timeout for the stream for read/write purpose.
+     *
+     * @param Integer $seconds      The part in seconds of the timeout
+     * @param Integer $microseconds The part in microseconds of the timeout
+     *
+     * @return StreamSocket $self Self-reference
+     */
+    public function set_timeout($seconds, $microseconds = 0)
+    {
+        if(is_int($seconds) && $seconds >= 0)
+        {
+            $this->timeout_seconds = $seconds;
+        }
+
+        if(is_int($microseconds) && $microseconds > 0)
+        {
+            $this->timeout_microseconds = $microseconds;
+        }
+
+        return $this;
+    }
+
+    /**
+     * Set the notification callback function of this stream stream context, see link for details.
+     *
+     * @param String $notification The notification function name
+     *
+     * @return StreamSocket $self Self-reference
+     * @link http://www.php.net/manual/en/function.stream-notification-callback.php
+     */
+    public function set_notification_callback($notification)
+    {
+        $this->notification = $notification;
+        return $this;
+    }
+
+    /**
+     * Tells wether the stream has data to read or not.
+     *
+     * @return Boolean $return TRUE if the socket has data to read, FALSE otherwise and
+     *                         NULL if the stream is closed or if an error occured
+     */
+    public function is_ready_to_read()
+    {
+        return $this->changed(TRUE, FALSE, FALSE);
+    }
+
+    /**
+     * Tells wether the stream is available for writing.
+     *
+     * @return Boolean $return TRUE if the socket is ready for writing, FALSE otherwise and
+     *                         NULL if the stream is closed or if an error occured
+     */
+    public function is_ready_to_write()
+    {
+        return $this->changed(FALSE, TRUE, FALSE);
+    }
+
+    /**
+     * Tells wether the stream is ready to read high priority exceptional ("out-of-band") data.
+     *
+     * @return mixed Boolean TRUE if the socket has thrown an exception, FALSE otherwise and
+     *                       NULL if the stream is closed or if an error occured
+     */
+    public function  is_ready_to_read_exceptional_data()
+    {
+        return $this->changed(FALSE, FALSE, TRUE);
+    }
+
+    /**
+     * Returns the changed state of this stream, if it is readable, writable, has exceptional data to read.
+     *
+     * @param boolean $read      Set to TRUE for testing read availability of the stream purpose
+     * @param boolean $write     Set to TRUE for testing write availability of the stream purpose
+     * @param boolean $exception Set to TRUE for testing exception thrown by the stream purpose
+     *
+     * @return Boolean $return TRUE state has change or launched an exception, FALSE otherwise and
+     *                         NULL if the stream is closed or if an error occured
+     */
+    protected function changed($read, $write, $exception)
+    {
+        if(!is_resource($this->handle))
+        {
+            return NULL;
+        }
+
+        $read_array   = $read      ? array($this->handle) : NULL;
+        $write_array  = $write     ? array($this->handle) : NULL;
+        $except_array = $exception ? array($this->handle) : NULL;
+
+        $changed = stream_select(
+                $read_array,
+                $write_array,
+                $except_array,
+                $this->timeout_seconds,
+                $this->timeout_microseconds
+                );
+
+        if($changed === FALSE)
+        {
+            return NULL;
+        }
+        else
+        {
+            return ($changed > 0);
+        }
+    }
+
+    /**
+     * Create the context of this stream with the options passed, callback function if set.
+     *
+     * @return resource $return The created context resource
+     */
+    protected function create_context()
+    {
+        $this->context = stream_context_create($this->context_options);
+
+        if(!empty($this->notification))
+        {
+            stream_context_set_params($this->context, array('notification' => $this->notification));
+        }
+
+        return $this->context;
+    }
+
+    /**
+     * Add the flag for stream resource creation.
+     *
+     * @param String $flag the flag identifier of the flag to add
+     *
+     * @return StreamSocket $self Self-reference
+     */
+    public abstract function add_flag($flag);
+
+    /**
+     * Create the resource handle of this stream socket.
+     *
+     * @return resource $return The created handle
+     */
+    protected abstract function create_handle();
+
+    /**
+     * Write the given data on the stream.
+     *
+     * @param mixed $data the data to write
+     *
+     * @return mixed $return the count of written bytes or FALSE if an error occurs
+     */
+    public abstract function write($data);
+
+    /**
+     * Read data from the stream.
+     *
+     * @param Integer $length The requested length of byte to read, all availdable data if -1(default value)
+     *
+     * @return String $return The n byte read from the stream, FALSE if an error occured
+     */
+    public abstract function read($length = -1);
+
+    /**
+     * Open the stream if not already opened.
+     *
+     * @return Boolean $return TRUE if the stream is open, FALSE otherwise
+     */
+    public abstract function connect();
+
+    /**
+     * Close the stream if not already closed, optional.
+     *
+     * @return Boolean $return TRUE if stream properly closed, FALSE om error
+     */
+    public abstract function disconnect();
+
+}
+
+?>
diff --git a/src/Lunr/Network/StreamSocketClient.php b/src/Lunr/Network/StreamSocketClient.php
new file mode 100644
index 0000000000000000000000000000000000000000..cfad6f3ce2044dd74a7ae01471fe775a4536438b
--- /dev/null
+++ b/src/Lunr/Network/StreamSocketClient.php
@@ -0,0 +1,248 @@
+<?php
+
+/**
+ * This file contains the stream socket client wrapper class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Libraries
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network;
+
+/**
+ * Stream socket client wrapper class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Libraries
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ */
+class StreamSocketClient extends StreamSocket
+{
+
+    /**
+     * The remote socket uri
+     * @var String
+     */
+    protected $uri;
+
+    /**
+     * The connection time out for this stream socket client
+     * @var Float
+     */
+    protected $init_timeout;
+
+    /**
+     * The connected status flag of this stream.
+     * @var Boolean
+     */
+    protected $connected;
+
+    /**
+     * Constructor.
+     *
+     * @param String $uri          The target uri of this client stream
+     * @param Float  $init_timeout The timeout value for stream socket creation,
+     *                             escaped to float if integer supplied, ignored
+     *                             otherwise
+     */
+    public function __construct($uri, $init_timeout = NULL)
+    {
+        parent::__construct();
+
+        $this->uri = $uri;
+
+        $this->init_timeout = floatval(ini_get('default_socket_timeout'));
+
+        if($init_timeout !== NULL)
+        {
+            if(is_int($init_timeout))
+            {
+                $init_timeout = floatval($init_timeout);
+            }
+
+            if(is_float($init_timeout))
+            {
+                $this->init_timeout = $init_timeout;
+            }
+        }
+
+        $this->connected = FALSE;
+    }
+
+    /**
+     * Destructor.
+     */
+    public function __destruct()
+    {
+        $this->disconnect();
+
+        unset($this->uri);
+        unset($this->init_timeout);
+
+        parent::__destruct();
+    }
+
+     /**
+     * Add the flag for stream resource creation.
+     *
+     * @param String $flag the flag indentifier of the flag to add
+     *
+     * @return StreamSocketClient $self Self-reference
+     */
+    public function add_flag($flag)
+    {
+        if((substr($flag, 0, 13) === 'STREAM_CLIENT') && (defined($flag) === TRUE))
+        {
+            $this->flags[$flag] = constant($flag);
+        }
+
+        return $this;
+    }
+
+    /**
+     * Create the resource handle of this stream socket, updates the meta data if stream connecteded.
+     *
+     * @return mixed $return The created handle, FALSE on failure
+     */
+    protected function create_handle()
+    {
+        $this->create_context();
+
+        if(empty($this->flags))
+        {
+            $flags = STREAM_CLIENT_CONNECT;
+        }
+        else
+        {
+            $flags = array_reduce($this->flags, array($this, 'create_flags'));
+        }
+
+        $this->handle = stream_socket_client(
+                $this->uri,
+                $this->errno,
+                $this->errmsg,
+                $this->init_timeout,
+                $flags,
+                $this->context
+        );
+
+        if(!is_resource($this->handle))
+        {
+            $this->handle = NULL;
+            return FALSE;
+        }
+
+        stream_set_blocking($this->handle, $this->blocking ? 1: 0);
+        stream_set_timeout($this->handle, $this->timeout_seconds, $this->timeout_microseconds);
+        //update the metadata
+        $this->meta_data = stream_get_meta_data($this->handle);
+
+        $this->connected = TRUE;
+
+        return $this->handle;
+    }
+
+    /**
+     * Creates the flag to be used for the handle creation.
+     *
+     * @param Integer $flags The holding value of the flags to be created
+     * @param Integer $flag  The value to add to the current flags
+     *
+     * @return Integer $flags The binary OR images of the flags used for the handle creation
+     */
+    private function create_flags($flags, $flag)
+    {
+        $flags = $flags | $flag;
+
+        return $flags;
+    }
+
+    /**
+     * Write the given data on the stream, updates the meta data if stream connecteded.
+     *
+     * @param mixed $data the data to write
+     *
+     * @return mixed $return the count of written bytes or FALSE if an error occurs
+     */
+    public function write($data)
+    {
+        if(!$this->connect())
+        {
+            return FALSE;
+        }
+
+        $return = fwrite($this->handle, $data);
+        //update the metadata
+        $this->meta_data = stream_get_meta_data($this->handle);
+
+        return $return;
+    }
+
+    /**
+     * Read data from the stream.
+     *
+     * @param Integer $length The requested length of byte to read, all availdable data if -1(default value)
+     *
+     * @return String $return The n byte read from the stream, FALSE if an error occured
+     */
+    public function read($length = -1)
+    {
+        if(!$this->connect())
+        {
+            return FALSE;
+        }
+
+        return stream_get_contents($this->handle, $length);
+    }
+
+    /**
+     * Open the stream if not already connecteded, handle created as consequence.
+     *
+     * Calling connected is optional as read, read_all and write call it as well.
+     *
+     * @return Boolean $return TRUE if the stream is connecteded, FALSE otherwise
+     */
+    public function connect()
+    {
+        if($this->connected)
+        {
+            return TRUE;
+        }
+
+        return is_resource($this->create_handle());
+    }
+
+    /**
+     * Close the resource associated to the stream, updates the metadata if stream not already closed.
+     *
+     * @return Boolean $return TRUE if successfully closed the resource, FALSE otherwise
+     */
+    public function disconnect()
+    {
+        if(! $this->connected)
+        {
+            return TRUE;
+        }
+
+        //update the metadata
+        $this->meta_data = stream_get_meta_data($this->handle);
+
+        $return = fclose($this->handle);
+
+        $this->handle = NULL;
+
+        $this->connected = FALSE;
+
+        return $return;
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketBaseTest.php b/src/Lunr/Network/Tests/StreamSocketBaseTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..c5a6e9762b7d25d13c7f526e0229e28e86e076fe
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketBaseTest.php
@@ -0,0 +1,165 @@
+<?php
+
+/**
+ * This file contains the StreamSocketBaseTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains basic test methods for the StreamSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocket
+ */
+class StreamSocketBaseTest extends StreamSocketTest
+{
+
+    /**
+     * Tests that context_options is an empty array by default.
+     */
+    public function testContextOptionsIsEmptyArray()
+    {
+        $property = $this->stream_socket_reflection->getProperty('context_options');
+        $property->setAccessible(TRUE);
+
+        $value = $property->getValue($this->stream_socket);
+
+        $this->assertInternalType('array', $value);
+        $this->assertEmpty($value);
+    }
+
+    /**
+     * Tests that meta data info is an empty array by default.
+     */
+    public function testMetaDataIsEmptyArray()
+    {
+        $property = $this->stream_socket_reflection->getProperty('meta_data');
+        $property->setAccessible(TRUE);
+
+        $value = $property->getValue($this->stream_socket);
+
+        $this->assertInternalType('array', $value);
+        $this->assertEmpty($value);
+    }
+
+    /**
+     * Tests that flags is an empty array by default.
+     */
+    public function testFlagsIsEmptyArray()
+    {
+        $property = $this->stream_socket_reflection->getProperty('flags');
+        $property->setAccessible(TRUE);
+
+        $value = $property->getValue($this->stream_socket);
+
+        $this->assertInternalType('array', $value);
+        $this->assertEmpty($value);
+    }
+
+    /**
+     * Tests that errno equals 0 by default.
+     */
+    public function testErrnoIsZero()
+    {
+        $property = $this->stream_socket_reflection->getProperty('errno');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals(0, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that blocking equals TRUE by default.
+     */
+    public function testBlockingIsOne()
+    {
+        $property = $this->stream_socket_reflection->getProperty('blocking');
+        $property->setAccessible(TRUE);
+
+        $this->assertTrue($property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that errmsg is an empty string by default.
+     */
+    public function testErrmsgIsEmptyString()
+    {
+        $property = $this->stream_socket_reflection->getProperty('errno');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals(0, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that notification is an empty string by default.
+     */
+    public function testNotificationIsEmptyString()
+    {
+        $property = $this->stream_socket_reflection->getProperty('notification');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals('', $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that handle is NULL by default.
+     */
+    public function testHandleIsNull()
+    {
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->assertNull($property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that context is NULL by default.
+     */
+    public function testContextIsNull()
+    {
+        $property = $this->stream_socket_reflection->getProperty('context');
+        $property->setAccessible(TRUE);
+
+        $this->assertNull($property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that timeout_seconds equals 60 by default.
+     */
+    public function testTimeoutSecondsInitValue()
+    {
+        $property = $this->stream_socket_reflection->getProperty('timeout_seconds');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals(60, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that timeout_micros equals 0 by default.
+     */
+    public function testTimeoutMicrosEqualsZero()
+    {
+        $property = $this->stream_socket_reflection->getProperty('timeout_microseconds');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals(0, $property->getValue($this->stream_socket));
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/src/Lunr/Network/Tests/StreamSocketClientBaseTest.php b/src/Lunr/Network/Tests/StreamSocketClientBaseTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..052e8b18316e5a6dd9fc379e32706a4a12e1b29d
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketClientBaseTest.php
@@ -0,0 +1,122 @@
+<?php
+
+/**
+ * This file contains the StreamSocketClientBaseTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains basic test methods for the StreamClientSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocketClient
+ */
+class StreamSocketClientBaseTest extends StreamSocketClientTest
+{
+
+    /**
+     * Tests that the stream socket client inits with the transmitted uri value through constructor.
+     *
+     * @covers Lunr\Network\StreamSocketClient::__construct
+     */
+    public function testUriIntisWithProvidedValue()
+    {
+        $stream = new \Lunr\Network\StreamSocketClient('alinktosee');
+
+        $property = $this->stream_socket_client_reflection->getProperty('uri');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals('alinktosee', $property->getValue($stream));
+
+        unset($stream);
+    }
+
+    /**
+     * Tests that the stream socket client inits with default connection time out.
+     *
+     * @covers Lunr\Network\StreamSocketClient::__construct
+     */
+    public function testTimeoutIntisWithDefault()
+    {
+        $property = $this->stream_socket_client_reflection->getProperty('init_timeout');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals(ini_get('default_socket_timeout'), $property->getValue($this->stream_socket_client));
+        $this->assertTrue(is_float($property->getValue($this->stream_socket_client)));
+    }
+
+    /**
+     * Tests that the stream socket client inits with provided valid connection time out.
+     *
+     * @param Integer $value    The value to set
+     * @param Integer $expected The expected result
+     *
+     * @dataProvider validInitTimeoutProvider
+     * @covers       Lunr\Network\StreamSocketClient::__construct
+     */
+    public function testTimeoutIntisWithValidValue($value, $expected)
+    {
+        $stream = new \Lunr\Network\StreamSocketClient('alinktosee', $value);
+
+        $property = $this->stream_socket_client_reflection->getProperty('init_timeout');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals($expected, $property->getValue($stream));
+
+        unset($stream);
+    }
+
+    /**
+     * Tests that the init doesn't set the time out when invalid value provided.
+     *
+     * @param mixed $value The value to set
+     *
+     * @dataProvider invalidInitTimeoutProvider
+     * @depends      Lunr\Network\Tests\StreamSocketClientBaseTest::testTimeoutIntisWithValidValue
+     * @covers       Lunr\Network\StreamSocketClient::__construct
+     */
+    public function testTimeoutInitsWithInvalidValue($value)
+    {
+        $stream = new \Lunr\Network\StreamSocketClient('alinktosee', $value);
+
+        $property = $this->stream_socket_client_reflection->getProperty('init_timeout');
+        $property->setAccessible(TRUE);
+
+        $this->assertEquals(floatval(ini_get('default_socket_timeout')), $property->getValue($stream));
+        $this->assertTrue($value !== $property->getValue($stream));
+
+        unset($stream);
+    }
+
+    /**
+     * Tests that the connected flag is FALSE by default.
+     *
+     * @covers Lunr\Network\StreamSocketClient::__construct
+     */
+    public function testConnectedIsFalse()
+    {
+        $property = $this->stream_socket_client_reflection->getProperty('connected');
+        $property->setAccessible(TRUE);
+
+        $this->assertFalse($property->getValue($this->stream_socket_client));
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/src/Lunr/Network/Tests/StreamSocketClientFlagsTest.php b/src/Lunr/Network/Tests/StreamSocketClientFlagsTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..9c181bdce738af28cad6abeb916b4efb44692982
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketClientFlagsTest.php
@@ -0,0 +1,119 @@
+<?php
+
+/**
+ * This file contains the StreamSocketClientFlagsTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for flags of the StreamClientSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocketClient
+ */
+class StreamSocketClientFlagsTest extends StreamSocketClientTest
+{
+
+    /**
+     * Tests that a valid flag is properly added if not present.
+     *
+     * @covers Lunr\Network\StreamSocketClient::add_flag
+     */
+    public function testAddValidFlagIfNotPresent()
+    {
+        $property = $this->stream_socket_client_reflection->getProperty('flags');
+        $property->setAccessible(TRUE);
+
+        $previous = $property->getValue($this->stream_socket_client);
+
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_PERSISTENT');
+
+        $new = $property->getValue($this->stream_socket_client);
+
+        $this->assertTrue(count($new) === count($previous) + 1);
+        $this->assertContains(STREAM_CLIENT_PERSISTENT, $new);
+
+        $previous = $property->getValue($this->stream_socket_client);
+
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_ASYNC_CONNECT');
+
+        $new = $property->getValue($this->stream_socket_client);
+
+        $this->assertTrue(count($new) === count($previous) + 1);
+        $this->assertContains(STREAM_CLIENT_ASYNC_CONNECT, $new);
+    }
+
+    /**
+     * Tests that a valid flag is not added if present.
+     *
+     * @covers Lunr\Network\StreamSocketClient::add_flag
+     */
+    public function testDoNotAddValidFlagIfPresent()
+    {
+        $property = $this->stream_socket_client_reflection->getProperty('flags');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_PERSISTENT');
+
+        $previous = $property->getValue($this->stream_socket_client);
+
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_PERSISTENT');
+
+        $new = $property->getValue($this->stream_socket_client);
+
+        $this->assertEquals($previous, $new);
+    }
+
+    /**
+     * Tests that an invalid flag is not added to flags.
+     *
+     * @dataProvider invalidFlagProvider
+     * @covers       Lunr\Network\StreamSocketClient::add_flag
+     */
+    public function testDoNotAddInvalidFlag()
+    {
+        $property = $this->stream_socket_client_reflection->getProperty('flags');
+        $property->setAccessible(TRUE);
+
+        $previous = $property->getValue($this->stream_socket_client);
+
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_PERSISTENT');
+
+        $new = $property->getValue($this->stream_socket_client);
+
+        $this->assertTrue(count($new) === count($previous) + 1);
+        $this->assertContains(STREAM_CLIENT_PERSISTENT, $new);
+    }
+
+    /**
+     * Tests that create_flags() merges the given int to the total.
+     *
+     * @covers Lunr\Network\StreamSocketClient::create_flags
+     */
+    public function testCreateFlags()
+    {
+        $method = $this->stream_socket_client_reflection->getMethod('create_flags');
+        $method->setAccessible(TRUE);
+
+        $this->assertEquals(3, $method->invokeArgs($this->stream_socket_client, array(2, 1)));
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketClientHandleTest.php b/src/Lunr/Network/Tests/StreamSocketClientHandleTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..20a4222fa71da3254ec2784364867ec0d4acde68
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketClientHandleTest.php
@@ -0,0 +1,283 @@
+<?php
+
+/**
+ * This file contains the StreamSocketClientHandleTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for stream handle resource of the StreamClientSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocketClient
+ */
+class StreamSocketClientHandleTest extends StreamSocketClientTest
+{
+
+    /**
+     * Tests that the call of create_handle() sets the handle to a resource.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::create_handle
+     */
+    public function testCreateHandle()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $method = $this->stream_socket_client_reflection->getMethod('create_handle');
+        $method->setAccessible(TRUE);
+
+        $method->invoke($this->stream_socket_client);
+
+        $this->assertTrue(is_resource($property->getValue($this->stream_socket_client)));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that create_handle() returns FALSE if error occurs.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::create_handle
+     */
+    public function testCreateHandleReturnsFalseOnError()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        $method = $this->stream_socket_client_reflection->getMethod('create_handle');
+        $method->setAccessible(TRUE);
+
+        $this->assertFalse($method->invoke($this->stream_socket_client));
+    }
+
+    /**
+     * Tests that the call of connect creates the handle.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::connect
+     */
+    public function testOpenCreatesHandle()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket_client->connect();
+
+        $this->assertTrue(is_resource($property->getValue($this->stream_socket_client)));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that the call of connect with a previously connected handle keeps it the same.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::connect
+     */
+    public function testOpenTwiceKeepsSameHandle()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket_client->connect();
+
+        $first = $property->getValue($this->stream_socket_client);
+
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_OTHER_HANDLE);
+
+        $this->stream_socket_client->connect();
+
+        $second = $property->getValue($this->stream_socket_client);
+
+        $this->assertEquals($first, $second);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that connect() returns FALSE if error occurs.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::connect
+     */
+    public function testOpenReturnsFalseOnError()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        $this->assertFalse($this->stream_socket_client->connect());
+    }
+
+    /**
+     * Tests that the call of disconnect() method sets the handle to null.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::disconnect
+     */
+    public function testCloseDestroysHandle()
+    {
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $connect = $this->stream_socket_client_reflection->getProperty('connected');
+        $connect->setAccessible(TRUE);
+        $connect->setValue($this->stream_socket_client, TRUE);
+
+        $property->setValue($this->stream_socket_client, fopen('./test.txt', 'a'));
+
+        $this->assertTrue(is_resource($property->getValue($this->stream_socket_client)));
+
+        $this->assertTrue($this->stream_socket_client->disconnect());
+
+        $this->assertNull($property->getValue($this->stream_socket_client));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that the call of disconnect() returns TRUE if handle is NULL.
+     *
+     * @covers Lunr\Network\StreamSocketClient::disconnect
+     */
+    public function testCloseReturnsTrueIfHandleIsNull()
+    {
+        $this->assertTrue($this->stream_socket_client->disconnect());
+    }
+
+    /**
+     * Tests that the call of disconnect() returns FALSE if error occurs.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::disconnect
+     */
+    public function testCloseReturnsFalseIfError()
+    {
+        $copy = 'tmpdisconnect';
+        runkit_function_copy('fclose', $copy);
+        runkit_function_redefine('fclose', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        $connect = $this->stream_socket_client_reflection->getProperty('connected');
+        $connect->setAccessible(TRUE);
+        $connect->setValue($this->stream_socket_client, TRUE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        $property->setValue($this->stream_socket_client, fopen('./test.txt', 'a'));
+
+        $this->assertFalse($this->stream_socket_client->disconnect());
+
+        runkit_function_remove('fclose');
+        runkit_function_rename($copy, 'fclose');
+
+    }
+
+    /**
+     * Tests that the call of disconnect() return TRUE on success.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::disconnect
+     */
+    public function testCloseReturnsTrueOnSuccess()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertTrue($this->stream_socket_client->connect());
+        runkit_function_redefine('fclose', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+
+        $this->assertTrue($this->stream_socket_client->disconnect());
+
+    }
+
+    /**
+     * Tests that create_handle() updates the meta_data.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::create_handle
+     */
+    public function testCreateHandleUpdatesMetaData()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $first = $property->getValue($this->stream_socket_client);
+
+        $method = $this->stream_socket_client_reflection->getMethod('create_handle');
+        $method->setAccessible(TRUE);
+
+        $method->invoke($this->stream_socket_client);
+
+        $second = $property->getValue($this->stream_socket_client);
+
+        $this->assertNotEquals($first, $second);
+    }
+
+    /**
+     * Tests that the addition of proper flags leads to a handle creation.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::create_handle
+     */
+    public function testCreateHandleWithFlags()
+    {
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $method = $this->stream_socket_client_reflection->getMethod('create_handle');
+        $method->setAccessible(TRUE);
+
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_ASYNC_CONNECT');
+        $this->stream_socket_client->add_flag('STREAM_CLIENT_PERSISTENT');
+
+        $method->invoke($this->stream_socket_client);
+
+        $this->assertNotNull($property->getValue($this->stream_socket_client));
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketClientReadWriteTest.php b/src/Lunr/Network/Tests/StreamSocketClientReadWriteTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..a2ef2f21575945f6cdd327bdd7b98b6a6681290f
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketClientReadWriteTest.php
@@ -0,0 +1,241 @@
+<?php
+
+/**
+ * This file contains the StreamSocketClientReadwriteTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for read and write methods of the StreamClientSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocketClient
+ */
+class StreamSocketClientReadWriteTest extends StreamSocketClientTest
+{
+
+    /**
+     * Tests that read() returns a string on success.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::read
+     */
+    public function testReadReturnsStringOnSuccess()
+    {
+        runkit_function_redefine('fread', '', self::STREAM_SOCKET_CLIENT_RETURN_STRING);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertTrue(is_string($this->stream_socket_client->read(8)));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that read() returns a string with no lenght supplied.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::read
+     */
+    public function testReadReturnsStringWithNoLengthSupplied()
+    {
+        runkit_function_redefine('stream_get_contents', '', self::STREAM_SOCKET_CLIENT_RETURN_STRING);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertTrue(is_string($this->stream_socket_client->read()));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that read() returns a string with zero lenght supplied.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::read
+     */
+    public function testReadReturnsStringWithZeroLengthSupplied()
+    {
+        runkit_function_redefine('stream_get_contents', '', self::STREAM_SOCKET_CLIENT_RETURN_STRING);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertTrue(is_string($this->stream_socket_client->read(-1)));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that read() returns FALSE on error.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::read
+     */
+    public function testReadReturnsFalseOnError()
+    {
+        runkit_function_redefine('stream_get_contents', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertFalse($this->stream_socket_client->read(8));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that read() create handle if stream not open.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::read
+     */
+    public function testReadOpensHandle()
+    {
+        runkit_function_redefine('stream_get_contents', '', self::STREAM_SOCKET_CLIENT_RETURN_STRING);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->assertNull($property->getValue($this->stream_socket_client));
+
+        $this->stream_socket_client->read(8);
+
+        $this->assertNotNull($property->getValue($this->stream_socket_client));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that read() returns FALSE if cannot open stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::read
+     */
+    public function testReadReturnsFalseIfCannotOpenStream()
+    {
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->assertFalse($this->stream_socket_client->read(8));
+
+        $this->assertNull($property->getValue($this->stream_socket_client));
+    }
+
+    /**
+     * Tests that write() returns an int on success.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::write
+     */
+    public function testWriteReturnsIntOnSuccess()
+    {
+        runkit_function_redefine('fwrite', '', self::STREAM_SOCKET_CLIENT_RETURN_EIGHT);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertTrue(is_int($this->stream_socket_client->write('12345678')));
+    }
+
+    /**
+     * Tests that write() returns FALSE on error.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::write
+     */
+    public function testWriteReturnsFalseOnError()
+    {
+        runkit_function_redefine('fwrite', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $this->assertFalse($this->stream_socket_client->write('12345678'));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that write() create handle if stream not open.
+     *
+     * @runInSeparateProcess
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::write
+     */
+    public function testWriteOpensHandle()
+    {
+        runkit_function_redefine('fwrite', '', self::STREAM_SOCKET_CLIENT_RETURN_EIGHT);
+
+        runkit_function_redefine('stream_set_timeout', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_set_blocking', '', self::STREAM_SOCKET_CLIENT_RETURN_TRUE);
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_HANDLE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->assertNull($property->getValue($this->stream_socket_client));
+
+        $this->stream_socket_client->write('12345678');
+
+        $this->assertNotNull($property->getValue($this->stream_socket_client));
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that write() returns FALSE if cannot open stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers Lunr\Network\StreamSocketClient::write
+     */
+    public function testWriteReturnsFalseIfCannotOpenStream()
+    {
+        runkit_function_redefine('stream_socket_client', '', self::STREAM_SOCKET_CLIENT_RETURN_FALSE);
+
+        $property = $this->stream_socket_client_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+
+        $this->assertFalse($this->stream_socket_client->write('12345678'));
+        $this->assertNull($property->getValue($this->stream_socket_client));
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketClientTest.php b/src/Lunr/Network/Tests/StreamSocketClientTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..08acabd3ec43a253e3eb94d10f5584702ee92707
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketClientTest.php
@@ -0,0 +1,149 @@
+<?php
+/**
+ * This file contains the StreamSocketClientTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for the StreamSocketClient class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocketClient
+ */
+abstract class StreamSocketClientTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * Instance of the StreamSocketClient class.
+     * @var StreamSocketClient
+     */
+    protected $stream_socket_client;
+
+    /**
+     * Reflection instance of the StreamSocketClient class.
+     * @var ReflectionClass
+     */
+    protected $stream_socket_client_reflection;
+
+    /**
+     * Runkit simulation code for returning TRUE.
+     * @var String
+     */
+    const STREAM_SOCKET_CLIENT_RETURN_TRUE = 'return TRUE;';
+
+    /**
+     * Runkit simulation code for returning FALSE.
+     * @var String
+     */
+    const STREAM_SOCKET_CLIENT_RETURN_FALSE = 'return FALSE;';
+
+    /**
+     * Runkit simulation code for returning handle.
+     * @var String
+     */
+    const STREAM_SOCKET_CLIENT_RETURN_HANDLE = 'return fopen("./test.txt", "a");';
+
+    /**
+     * Runkit simulation code for returning handle.
+     * @var String
+     */
+    const STREAM_SOCKET_CLIENT_RETURN_OTHER_HANDLE = 'return fopen("./test2.txt", "a");';
+
+    /**
+     * Runkit simulation code for returning int.
+     * @var String
+     */
+    const STREAM_SOCKET_CLIENT_RETURN_EIGHT = 'return 8;';
+
+    /**
+     * Runkit simulation code for returning int.
+     * @var String
+     */
+    const STREAM_SOCKET_CLIENT_RETURN_STRING = 'return "string";';
+
+    /**
+     * TestCase Constructor.
+     */
+    public function setUp()
+    {
+        $this->stream_socket_client_reflection = new ReflectionClass('Lunr\Network\StreamSocketClient');
+
+        $this->stream_socket_client = new \Lunr\Network\StreamSocketClient('');
+    }
+
+    /**
+     * TestCase Destructor.
+     */
+    public function tearDown()
+    {
+        unset($this->stream_socket_client_reflection);
+        unset($this->stream_socket_client);
+    }
+
+    /**
+     * Unit Test Case Provider for valid init time out value provider.
+     *
+     * @return array $return The valid values for init time out
+     */
+    public function validInitTimeoutProvider()
+    {
+        $timeout   = array();
+        $timeout[] = array(1, 1.0);
+        $timeout[] = array(1.0, 1.0);
+        $timeout[] = array(1000, 1000.0);
+        $timeout[] = array(1000.0, 1000.0);
+
+        return $timeout;
+    }
+
+    /**
+     * Unit Test Case Provider for invalid init time out value.
+     *
+     * @return array $return The invalid values for init time out
+     */
+    public function invalidInitTimeoutProvider()
+    {
+        $timeout   = array();
+        $timeout[] = array(FALSE);
+        $timeout[] = array(NULL);
+        $timeout[] = array(TRUE);
+        $timeout[] = array('str');
+        $timeout[] = array('1234');
+
+        return $timeout;
+    }
+
+    /**
+     * Unit Test Case Provider for invalid flag value.
+     *
+     * @return array $return The invalid values for flag
+     */
+    public function invalidFlagProvider()
+    {
+        $flags   = array();
+        $flags[] = array('STREAM_PERS');
+        $flags[] = array('STRAM_PERS');
+        $flags[] = array('STREAM_CLIENT');
+        $flags[] = array('STREAM_CLIENT_A_FLAG');
+
+        return $flags;
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketContextTest.php b/src/Lunr/Network/Tests/StreamSocketContextTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..56cc8538670edc063b7437f7c5b3be7324dfc394
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketContextTest.php
@@ -0,0 +1,139 @@
+<?php
+
+/**
+ * This file contains the StreamSocketExecuteTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for stream context of the StreamSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocket
+ */
+class StreamSocketContextTest extends StreamSocketTest
+{
+
+    /**
+     * Tests that create_context() methods sets the stream context options.
+     *
+     * @covers  Lunr\Network\StreamSocket::create_context
+     */
+    public function testCreateContextSetsContextOptionsIfContextOptionsNotEmpty()
+    {
+        $property = $this->stream_socket_reflection->getProperty('context');
+        $property->setAccessible(TRUE);
+
+        $value = array( 'http' => array('method' => ' POST'));
+
+        $this->stream_socket->set_context_options($value);
+
+        $method = $this->stream_socket_reflection->getMethod('create_context');
+        $method->setAccessible(TRUE);
+
+        $method->invoke($this->stream_socket);
+
+        $options = stream_context_get_options($property->getValue($this->stream_socket));
+
+        $this->assertArrayHasKey('http', $options);
+        $this->assertEquals($value['http'], $options['http']);
+    }
+
+    /**
+     * Tests that create_context() methods sets nothing if no context options set.
+     *
+     * @covers  Lunr\Network\StreamSocket::create_context
+     */
+    public function testCreateContextDoesNotSetContextOptionsIfContextOptionsEmpty()
+    {
+        $property = $this->stream_socket_reflection->getProperty('context');
+        $property->setAccessible(TRUE);
+
+        $method = $this->stream_socket_reflection->getMethod('create_context');
+        $method->setAccessible(TRUE);
+
+        $method->invoke($this->stream_socket);
+
+        $this->assertEmpty(stream_context_get_options($property->getValue($this->stream_socket)));
+    }
+
+    /**
+     * Tests that create_context() methods sets the notification callback method.
+     *
+     * @covers  Lunr\Network\StreamSocket::create_context
+     */
+    public function testCreateContextSetsNotificationCallbackIfNotificationNotEmpty()
+    {
+        $property = $this->stream_socket_reflection->getProperty('context');
+        $property->setAccessible(TRUE);
+
+        $notification = 'notification';
+
+        $this->stream_socket->set_notification_callback($notification);
+
+        $method = $this->stream_socket_reflection->getMethod('create_context');
+        $method->setAccessible(TRUE);
+
+        $method->invoke($this->stream_socket);
+
+        $params = stream_context_get_params($property->getValue($this->stream_socket));
+
+        $this->assertArrayHasKey('notification', $params);
+        $this->assertEquals($notification, $params['notification']);
+    }
+
+    /**
+     * Tests that create_context() does not set notification callback method if notification is empty.
+     *
+     * @covers  Lunr\Network\StreamSocket::create_context
+     */
+    public function testCreateContextDoesNotSetNotificationCallbackIfNotificationEmpty()
+    {
+        $property = $this->stream_socket_reflection->getProperty('context');
+        $property->setAccessible(TRUE);
+
+        $method = $this->stream_socket_reflection->getMethod('create_context');
+        $method->setAccessible(TRUE);
+
+        $method->invoke($this->stream_socket);
+
+        $params = stream_context_get_params($property->getValue($this->stream_socket));
+
+        $this->assertArrayNotHasKey('notification', $params);
+    }
+
+    /**
+     * Tests that create_context() method returns a context resource.
+     *
+     * @covers  Lunr\Network\StreamSocket::create_context
+     */
+    public function testCreateContextReturnsResource()
+    {
+        $method = $this->stream_socket_reflection->getMethod('create_context');
+        $method->setAccessible(TRUE);
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertTrue(is_resource($return));
+        $this->assertEquals('stream-context', get_resource_type($return));
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketSetGetTest.php b/src/Lunr/Network/Tests/StreamSocketSetGetTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..7c0054da7fcae1774fa8fa961e59cda24b163347
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketSetGetTest.php
@@ -0,0 +1,345 @@
+<?php
+
+/**
+ * This file contains the StreamSocketSetGetTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for the getters and setters of the StreamSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocket
+ */
+class StreamSocketSetGetTest extends StreamSocketTest
+{
+
+    /**
+     * Tests that the value of valid properties can be retrieved correctly.
+     *
+     * @param String $property Property name
+     * @param mixed  $value    Property value
+     *
+     * @dataProvider validPropertyProvider
+     * @covers       Lunr\Network\StreamSocket::__get
+     */
+    public function testGetReturnsValuesForValidProperties($property, $value)
+    {
+        $this->assertEquals($value, $this->stream_socket->$property);
+    }
+
+    /**
+     * Tests that the value of invalid properties is retrieved as NULL.
+     *
+     * @covers Lunr\Network\StreamSocket::__get
+     */
+    public function testGetReturnsNullForInvalidProperties()
+    {
+        $this->assertNull($this->stream_socket->invalid_property);
+    }
+
+    /**
+     * Tests that set_context_option() sets properly the option and its value in the correct wrapper.
+     *
+     * @param String $wrapper The wrapper to set the option in
+     * @param String $option  The option to set within the wrapper
+     * @param mixed  $value   The value of the set option
+     *
+     * @dataProvider validWrapperProvider
+     * @covers       Lunr\Network\StreamSocket::set_context_option
+     */
+    public function testSetContextOptionWithValidWrapper($wrapper, $option, $value)
+    {
+        $property = $this->stream_socket_reflection->getProperty('context_options');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket->set_context_option($wrapper, $option, $value);
+
+        $context = $property->getValue($this->stream_socket);
+
+        $this->assertArrayHasKey($wrapper, $context);
+
+        $this->assertArrayHasKey($option, $context[$wrapper]);
+        $this->assertEquals($value, $context[$wrapper][$option]);
+    }
+
+    /**
+     * Tests that the context_options property is not modified with illegal or invalid wrapper.
+     *
+     * @param String $wrapper The wrapper to set the option in
+     * @param String $option  The option to set within the wrapper
+     * @param mixed  $value   The value of the set option
+     *
+     * @dataProvider invalidWrapperProvider
+     * @depends      Lunr\Network\Tests\StreamSocketSetGetTest::testSetContextOptionWithValidWrapper
+     * @covers       Lunr\Network\StreamSocket::set_context_option
+     */
+    public function testSetContextOptionWithInvalidWrapper($wrapper, $option, $value)
+    {
+        $property = $this->stream_socket_reflection->getProperty('context_options');
+        $property->setAccessible(TRUE);
+
+        $previous = $property->getValue($this->stream_socket);
+
+        $this->stream_socket->set_context_option($wrapper, $option, $value);
+
+        $this->assertEquals($previous, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that set_context_options() sets properly the given array.
+     *
+     * @depends Lunr\Network\Tests\StreamSocketSetGetTest::testSetContextOptionWithValidWrapper
+     * @covers  Lunr\Network\StreamSocket::set_context_options
+     */
+    public function testSetContextOptionsWithValidInput()
+    {
+        $options = array(
+            'http' => array('method' => 'POST'),
+            'ftp'  => array('overwrite' => FALSE),
+            'tcp'  => array('bindto' => '127.0.0.1:4321'),
+        );
+
+        $property = $this->stream_socket_reflection->getProperty('context_options');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket->set_context_options($options);
+
+        $context = $property->getValue($this->stream_socket);
+
+        foreach($options as $wrapper_key => $wrapper)
+        {
+            $this->assertArrayHasKey($wrapper_key, $context);
+
+            foreach($wrapper as $option => $value)
+            {
+                $this->assertArrayHasKey($option, $wrapper);
+                $this->assertEquals($value, $wrapper[$option]);
+            }
+        }
+    }
+
+    /**
+     * Tests that set_options() does not do anything if input is not an array.
+     *
+     * @param mixed $value The non-array invalid input
+     *
+     * @dataProvider invalidOptionsProvider
+     * @covers       Lunr\Network\StreamSocket::set_context_options
+     */
+    public function testSetContextOptionsIfInputIsNotArray($value)
+    {
+        $property = $this->stream_socket_reflection->getProperty('context_options');
+        $property->setAccessible(TRUE);
+
+        $previous = $property->getValue($this->stream_socket);
+
+        $this->stream_socket->set_context_options($value);
+
+        $this->assertEquals($previous, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that the blocking property is properly set with valid values.
+     *
+     * @param Boolean $value A valid value for blocking property
+     *
+     * @dataProvider validBlockingProvider
+     * @covers       Lunr\Network\StreamSocket::set_blocking
+     */
+    public function testSetBlockingWithValidInput($value)
+    {
+        $property = $this->stream_socket_reflection->getProperty('blocking');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket->set_blocking($value);
+
+        $this->assertEquals($value, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that blocking property is not modified if invalid input provided.
+     *
+     * @param mixed $value A invalid value for blocking property
+     *
+     * @dataProvider invalidBlockingProvider
+     * @covers       Lunr\Network\StreamSocket::set_blocking
+     */
+    public function testSetBlockingWithInvalidInput($value)
+    {
+        $property = $this->stream_socket_reflection->getProperty('blocking');
+        $property->setAccessible(TRUE);
+
+        $previous = $property->getValue($this->stream_socket);
+
+        $this->stream_socket->set_blocking($value);
+
+        $this->assertEquals($previous, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that notification property is properly set.
+     *
+     * @covers Lunr\Network\StreamSocket::set_notification_callback
+     */
+    public function testSetNotificationCallBack()
+    {
+        $value = 'notification';
+
+        $property = $this->stream_socket_reflection->getProperty('notification');
+        $property->setAccessible(TRUE);
+
+        $this->stream_socket->set_notification_callback($value);
+
+        $this->assertEquals($value, $property->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that timeout_seconds is properly set with valid value.
+     *
+     * @param Integer $seconds The timeout part in seconds to test
+     * @param Integer $micros  The timeout part in microseconds to test
+     *
+     * @dataProvider validTimeoutProvider
+     * @covers       Lunr\Network\StreamSocket::set_timeout
+     */
+    public function testSetTimeoutWithValidValue($seconds, $micros)
+    {
+        $timeout_seconds = $this->stream_socket_reflection->getProperty('timeout_seconds');
+        $timeout_seconds->setAccessible(TRUE);
+
+        $timeout_microseconds = $this->stream_socket_reflection->getProperty('timeout_microseconds');
+        $timeout_microseconds->setAccessible(TRUE);
+
+        $this->stream_socket->set_timeout($seconds, $micros);
+
+        $this->assertEquals($seconds, $timeout_seconds->getValue($this->stream_socket));
+        $this->assertEquals($micros, $timeout_microseconds->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that timeout_seconds is not set with invalid value.
+     *
+     * @param Integer $seconds The timeout part in seconds to test
+     * @param Integer $micros  The timeout part in microseconds to test
+     *
+     * @dataProvider invalidTimeoutProvider
+     * @covers       Lunr\Network\StreamSocket::set_timeout
+     */
+    public function testSetTimeoutWithInvalidValue($seconds, $micros)
+    {
+        $timeout_seconds = $this->stream_socket_reflection->getProperty('timeout_seconds');
+        $timeout_seconds->setAccessible(TRUE);
+
+        $timeout_microseconds = $this->stream_socket_reflection->getProperty('timeout_microseconds');
+        $timeout_microseconds->setAccessible(TRUE);
+
+        $this->stream_socket->set_timeout($seconds, $micros);
+
+        $this->assertFalse($seconds === $timeout_seconds->getValue($this->stream_socket));
+        $this->assertFalse($micros === $timeout_microseconds->getValue($this->stream_socket));
+    }
+
+    /**
+     * Tests that the set timeout method with default microseconds parameter.
+     *
+     * @covers Lunr\Network\StreamSocket::set_timeout
+     */
+    public function testSetTimeoutWithDefaultMicroseconds()
+    {
+        $timeout_seconds = $this->stream_socket_reflection->getProperty('timeout_seconds');
+        $timeout_seconds->setAccessible(TRUE);
+
+        $timeout_microseconds = $this->stream_socket_reflection->getProperty('timeout_microseconds');
+        $timeout_microseconds->setAccessible(TRUE);
+
+        $value = $timeout_microseconds->getValue($this->stream_socket);
+
+        $this->stream_socket->set_timeout(1);
+
+        $this->assertTrue(1 === $timeout_seconds->getValue($this->stream_socket));
+        $this->assertTrue(0 === $timeout_microseconds->getValue($this->stream_socket));
+        $this->assertSame($value, $timeout_microseconds->getValue($this->stream_socket));
+    }
+    
+    /**
+     * Test the fluid interface of the set_context_option() method.
+     *
+     * @covers Lunr\Network\StreamSocket::set_context_option
+     */
+    public function testSetContextOptionReturnsSelfReference()
+    {
+        $return = $this->stream_socket->set_context_option('http', 'method', 'POST');
+
+        $this->assertEquals($return, $this->stream_socket);
+    }
+
+    /**
+     * Test the fluid interface of the set_context_options() method.
+     *
+     * @covers Lunr\Network\StreamSocket::set_context_options
+     */
+    public function testSetContextOptionsReturnsSelfReference()
+    {
+        $value = array('http' => array('method' => 'POST'));
+
+        $return = $this->stream_socket->set_context_options($value);
+
+        $this->assertEquals($return, $this->stream_socket);
+    }
+
+    /**
+     * Test the fluid interface of the set_blocking() method.
+     *
+     * @covers Lunr\Network\StreamSocket::set_blocking
+     */
+    public function testSetBlockingReturnsSelfReference()
+    {
+        $return = $this->stream_socket->set_blocking(0);
+
+        $this->assertEquals($return, $this->stream_socket);
+    }
+
+    /**
+     * Test the fluid interface of the set_notification_callback() method.
+     *
+     * @covers Lunr\Network\StreamSocket::set_notification_callback
+     */
+    public function testSetNotificationCallbackReturnsSelfReference()
+    {
+        $return = $this->stream_socket->set_notification_callback('notification');
+
+        $this->assertEquals($return, $this->stream_socket);
+    }
+
+    /**
+     * Test the fluid interface of the set_timeout() method.
+     *
+     * @covers Lunr\Network\StreamSocket::set_timeout
+     */
+    public function testSetTimeoutReturnsSelfReference()
+    {
+        $return = $this->stream_socket->set_timeout(1);
+
+        $this->assertEquals($return, $this->stream_socket);
+    }
+
+}
+
+?>
diff --git a/src/Lunr/Network/Tests/StreamSocketStateTest.php b/src/Lunr/Network/Tests/StreamSocketStateTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..67844d6f051831d71001540d5e9a5b1e6b1eec13
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketStateTest.php
@@ -0,0 +1,514 @@
+<?php
+
+/**
+ * This file contains the StreamSocketStateTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for state change StreamSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocket
+ */
+class StreamSocketStateTest extends StreamSocketTest
+{
+
+    /**
+     * Tests that changed() method returns TRUE if the stream can be read.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsTrueOnReadWatchOfTheStreamIfChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ONE);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(TRUE, FALSE, FALSE));
+
+        $this->assertTrue($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() method returns FALSE if the stream cannot be read.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsFalseOnReadWatchOfTheStreamIfNotChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ZERO);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(TRUE, FALSE, FALSE));
+
+        $this->assertFalse($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() returns NULL if error occurs while watching read availability of the stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsNullOnReadWatchOfTheStreamIfError()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_FALSE);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(TRUE, FALSE, FALSE));
+
+        $this->assertNull($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() method returns TRUE if the stream can be written.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsTrueOnWriteWatchOfTheStreamIfChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ONE);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, TRUE, FALSE));
+
+        $this->assertTrue($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() method returns FALSE if the stream cannot be written.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsFalseOnWriteWatchOfTheStreamIfNotChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ZERO);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, TRUE, FALSE));
+
+        $this->assertFalse($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() returns NULL if error occurs while watching write availability of the stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsNullOnWriteWatchOfTheStreamIfError()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_FALSE);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, TRUE, FALSE));
+
+        $this->assertNull($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() method returns TRUE if the stream has thrown an exception.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsTrueOnExceptionWatchOfTheStreamIfChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ONE);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+
+        $this->assertTrue($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() method returns FALSE if the stream has not thrown an exception.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsFalseOnExceptionWatchOfTheStreamIfNotChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ZERO);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+
+        $this->assertFalse($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() returns NULL if error occurs while watching exception purpose of the stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsNullOnexceptionWatchOfTheStreamIfError()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_FALSE);
+
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+
+        $this->assertNull($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that changed() returns NULL if stream is not open for all type of watch.
+     *
+     * @covers  Lunr\Network\StreamSocket::changed
+     */
+    public function testChangedReturnsNullIfStreamNotOpened()
+    {
+        $method = $this->stream_socket_reflection->getMethod('changed');
+        $method->setAccessible(TRUE);
+
+        $return = $method->invokeArgs($this->stream_socket, array(TRUE, FALSE, FALSE));
+        $this->assertNull($return);
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, TRUE, FALSE));
+        $this->assertNull($return);
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+        $this->assertNull($return);
+    }
+
+    /**
+     * Tests that is_ready_to_read() returns TRUE if the stream can be read.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsTrueOnReadWatchOfTheStreamIfChanged
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_read
+     */
+    public function testIsReadyToReadReturnsTrueIfStreamChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ONE);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_read');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertTrue($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_read() method returns FALSE if the stream cannot be read.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsFalseOnReadWatchOfTheStreamIfNotChanged
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_read
+     */
+    public function testIsReadyToReadReturnsFalseIfStreamNotChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ZERO);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_read');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertFalse($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_read() returns NULL if error occurs while watching read availability of the stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsNullOnReadWatchOfTheStreamIfError
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_read
+     */
+    public function testIsReadyToReadReturnsNullIfError()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_FALSE);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_read');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertNull($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_write() method returns TRUE if the stream can be written.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsTrueOnWriteWatchOfTheStreamIfChanged
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_write
+     */
+    public function testIsReadyToWriteReturnsTrueIfStreamChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ONE);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_write');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertTrue($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_write() method returns FALSE if the stream cannot be written.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsFalseOnWriteWatchOfTheStreamIfNotChanged
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_write
+     */
+    public function testIsReadyToWriteReturnsFalseIfStreamNotChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ZERO);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_write');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertFalse($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_write() returns NULL if error occurs while watching write availability of the stream.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsNullOnWriteWatchOfTheStreamIfError
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_write
+     */
+    public function testIsReadyToWriteReturnsNullIfError()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_FALSE);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_write');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invoke($this->stream_socket);
+
+        $this->assertNull($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_read_exceptional_data() returns TRUE if the stream has thrown an exception.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsTrueOnExceptionWatchOfTheStreamIfChanged
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_read_exceptional_data
+     */
+    public function testIsReadyToreadExceptionnalDataReturnsTrueIfStreamChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ONE);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_read_exceptional_data');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+
+        $this->assertTrue($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_read_exceptional_data() returns FALSE if the stream has not exceptional data.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsFalseOnExceptionWatchOfTheStreamIfNotChanged
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_read_exceptional_data
+     */
+    public function testIsReadyToreadExceptionnalDataReturnsFalseIfStreamNotChanged()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_ZERO);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_read_exceptional_data');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+
+        $this->assertFalse($return);
+
+        unlink('./test.txt');
+    }
+
+    /**
+     * Tests that is_ready_to_read_exceptional_data() returns NULL if error occurs.
+     *
+     * @depends Lunr\EnvironmentTest::testRunkit
+     * @depends Lunr\Network\Tests\StreamSocketStateTest::testChangedReturnsNullOnexceptionWatchOfTheStreamIfError
+     * @covers  Lunr\Network\StreamSocket::is_ready_to_read_exceptional_data
+     */
+    public function testIsReadyToreadExceptionnalDataReturnsNullIfError()
+    {
+        runkit_function_redefine('stream_select', '', self::STREAM_SOCKET_RETURN_FALSE);
+
+        $method = $this->stream_socket_reflection->getMethod('is_ready_to_read_exceptional_data');
+        $method->setAccessible(TRUE);
+
+        $property = $this->stream_socket_reflection->getProperty('handle');
+        $property->setAccessible(TRUE);
+        //to prevent the method to try to create the handle
+        $property->setValue($this->stream_socket, fopen('./test.txt', 'a'));
+
+        $return = $method->invokeArgs($this->stream_socket, array(FALSE, FALSE, TRUE));
+
+        $this->assertNull($return);
+
+        unlink('./test.txt');
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/src/Lunr/Network/Tests/StreamSocketTest.php b/src/Lunr/Network/Tests/StreamSocketTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..371790b2dd8a0dbd3a75ceca88be1fe3457775df
--- /dev/null
+++ b/src/Lunr/Network/Tests/StreamSocketTest.php
@@ -0,0 +1,245 @@
+<?php
+
+/**
+ * This file contains the StreamSocketTest class.
+ *
+ * PHP Version 5.3
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @copyright  2012, M2Mobi BV, Amsterdam, The Netherlands
+ * @license    http://lunr.nl/LICENSE MIT License
+ */
+
+namespace Lunr\Network\Tests;
+
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * This class contains test methods for the StreamSocket class.
+ *
+ * @category   Libraries
+ * @package    Network
+ * @subpackage Tests
+ * @author     Olivier Wizen <olivier@m2mobi.com>
+ * @covers     Lunr\Network\StreamSocket
+ */
+abstract class StreamSocketTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * Instance of the StreamSocket class.
+     * @var StreamSocket
+     */
+    protected $stream_socket;
+
+    /**
+     * Reflection instance of the StreamSocket class.
+     * @var ReflectionClass
+     */
+    protected $stream_socket_reflection;
+
+    /**
+     * Runkit simulation code for returning FALSE.
+     * @var string
+     */
+    const STREAM_SOCKET_RETURN_FALSE = 'return FALSE;';
+
+    /**
+     * Runkit simulation code for returning TRUE.
+     * @var string
+     */
+    const STREAM_SOCKET_RETURN_TRUE = 'return TRUE;';
+
+    /**
+     * Runkit simulation code for returning NULL.
+     * @var string
+     */
+    const STREAM_SOCKET_RETURN_NULL = 'return NULL;';
+
+    /**
+     * Runkit simulation code for returning 1.
+     * @var string
+     */
+    const STREAM_SOCKET_RETURN_ONE = 'return 1;';
+
+    /**
+     * Runkit simulation code for returning 0.
+     * @var string
+     */
+    const STREAM_SOCKET_RETURN_ZERO = 'return 0;';
+
+    /**
+     * TestCase Constructor.
+     */
+    public function setUp()
+    {
+        $this->stream_socket_reflection = new ReflectionClass('Lunr\Network\StreamSocket');
+
+        $this->stream_socket = $this->getMockForAbstractClass('Lunr\Network\StreamSocket');
+    }
+
+    /**
+     * TestCase Destructor.
+     */
+    public function tearDown()
+    {
+        unset($this->stream_socket_reflection);
+        unset($this->stream_socket);
+    }
+
+    /**
+     * Unit Test Data Provider for valid property values.
+     *
+     * @return array $properties Array of valid properties of the StreamSocket class
+     */
+    public function validPropertyProvider()
+    {
+        $properties   = array();
+        $properties[] = array('errno', 0);
+        $properties[] = array('errmsg', '');
+        $properties[] = array('meta_data', array());
+
+        return $properties;
+    }
+
+    /**
+     * Unit Test data Provider for valid wrapper values.
+     *
+     * @return array $wrappers Array of valid wrappers of the stream socket class
+     *                         with option and value
+     */
+    public function validWrapperProvider()
+    {
+        $wrappers   = array();
+        $wrappers[] = array('http', 'method', 'POST');
+        $wrappers[] = array('ftp', 'overwrite', FALSE);
+        $wrappers[] = array('tcp', 'bla', '127.0.0.1:4321');
+
+        return $wrappers;
+    }
+
+    /**
+     * Unit Test Data Provider for valid wrapper values.
+     *
+     * @return array $wrappers Array of valid wrappers of the stream socket class
+     *                         with option and value
+     */
+    public function invalidWrapperProvider()
+    {
+        $wrappers   = array();
+        $wrappers[] = array('beuh', 'method', 'POST');
+        $wrappers[] = array('hein', 'overwrite', FALSE);
+        $wrappers[] = array('quoi', 'bla', '127.0.0.1:4321');
+        $wrappers[] = array(1, 1, 1);
+        $wrappers[] = array(0, 1, 1);
+        $wrappers[] = array(TRUE, 'TRUE', 'TRUE');
+        $wrappers[] = array(FALSE, 'FALSE', 'FALSE');
+        $wrappers[] = array(NULL, 'NULL', 'NULL');
+
+        return $wrappers;
+    }
+
+    /**
+     * Unit Test Data Provider for invalid context options values.
+     *
+     * @return array $options The invalid options values
+     */
+    public function invalidOptionsProvider()
+    {
+        $option    = array();
+        $options[] = array('str');
+        $options[] = array(0);
+        $options[] = array(1);
+        $options[] = array(-1);
+        $options[] = array(37);
+        $options[] = array(NULL);
+        $options[] = array(FALSE);
+        $options[] = array(TRUE);
+
+        return $options;
+    }
+
+    /**
+     * Unit Test Data Povider for valid blocking values.
+     *
+     * @return array $blockings The array of valid blocking values
+     */
+    public function validBlockingProvider()
+    {
+        $blockings   = array();
+        $blockings[] = array(TRUE);
+        $blockings[] = array(FALSE);
+
+        return $blockings;
+    }
+
+    /**
+     * Unit Test Data Povider for invalid blocking values.
+     *
+     * @return array $blockings The array of invalid blocking values
+     */
+    public function invalidBlockingProvider()
+    {
+        $blockings   = array();
+        $blockings[] = array(0);
+        $blockings[] = array(1);
+        $blockings[] = array(-1);
+        $blockings[] = array(2);
+        $blockings[] = array(1000);
+        $blockings[] = array(39);
+        $blockings[] = array('1');
+        $blockings[] = array('str');
+        $blockings[] = array(0.5);
+        $blockings[] = array(3.9);
+        $blockings[] = array(-4.7);
+        $blockings[] = array(NULL);
+
+        return $blockings;
+    }
+
+    /**
+     * Unit Test Data Provider for valid timeout values.
+     *
+     * @return array $timeouts The array of valid timeout values
+     */
+    public function validTimeoutProvider()
+    {
+        $timeouts   = array();
+        $timeouts[] = array(999, 999);
+        $timeouts[] = array(1, 1);
+        $timeouts[] = array(0, 1);
+        $timeouts[] = array(10, 12);
+        $timeouts[] = array(100, 1);
+        $timeouts[] = array(1000, 500);
+        $timeouts[] = array(0, NULL);
+
+        return $timeouts;
+    }
+
+    /**
+     * Unit Test Data Provider for invalid timeout values.
+     *
+     * @return array $timeouts The array of invalid timeout values
+     */
+    public function invalidTimeoutProvider()
+    {
+        $timeouts   = array();
+        $timeouts[] = array('0', NULL);
+        $timeouts[] = array('1', '1');
+        $timeouts[] = array(-1, -1);
+        $timeouts[] = array(-10, -10);
+        $timeouts[] = array( '100', -100);
+        $timeouts[] = array(26.87, 52.87);
+        $timeouts[] = array(NULL, NULL);
+        $timeouts[] = array(FALSE, FALSE);
+        $timeouts[] = array(TRUE, TRUE);
+
+        return $timeouts;
+    }
+
+}
+
+?>
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index e9fe1ed1e5b31bdc442eb6a6e77c6ee81a7c137d..5572a6ee4db702e530f3fb9c6baf87cd4607d119 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -60,6 +60,14 @@
             <file>src/Lunr/Network/Tests/CurlSetGetTest.php</file>
             <file>src/Lunr/Network/Tests/CurlExecuteTest.php</file>
             <file>src/Lunr/Network/Tests/CurlRequestTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketBaseTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketContextTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketSetGetTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketStateTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketClientBaseTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketClientFlagsTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketClientHandleTest.php</file>
+            <file>src/Lunr/Network/Tests/StreamSocketClientReadWriteTest.php</file>
             <file>src/Lunr/DataAccess/Tests/MySQLQueryResultBaseTest.php</file>
             <file>src/Lunr/DataAccess/Tests/MySQLQueryResultFailedTest.php</file>
             <file>src/Lunr/DataAccess/Tests/MySQLQueryResultSuccessTest.php</file>
