void Main()
        {
            // connect with a 5 second timeout on the connection
            var connection = new TcpClientWithTimeout(
                "www.google.com", 80, TimeSpan.FromSeconds(5)).Connect();

            var stream = connection.GetStream();

            // Send 10 bytes
            byte[] toSend = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
            stream.Write(toSend, 0, toSend.Length);

            // ReceiveMessages 10 bytes
            var readbuf = new byte[10]; // you must allocate space first
            stream.ReadTimeout = 10000; // 10 second timeout on the read
            stream.Read(readbuf, 0, 10); // read

            // Disconnect nicely
            stream.Close(); // workaround for a .net bug: http://support.microsoft.com/kb/821625
            connection.Close();
        }
        void Main()
        {
            // connect with a 5 second timeout on the connection
            var connection = new TcpClientWithTimeout(
                "www.google.com", 80, TimeSpan.FromSeconds(5)).Connect();

            var stream = connection.GetStream();

            // Send 10 bytes
            byte[] toSend = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xa };
            stream.Write(toSend, 0, toSend.Length);

            // ReceiveMessages 10 bytes
            var readbuf = new byte[10];  // you must allocate space first

            stream.ReadTimeout = 10000;  // 10 second timeout on the read
            stream.Read(readbuf, 0, 10); // read

            // Disconnect nicely
            stream.Close(); // workaround for a .net bug: http://support.microsoft.com/kb/821625
            connection.Close();
        }