private void connectConnection(String host, int port)
        throws ChannelError {
		
        if (HydnaDebug.HYDNADEBUG) {
            DebugHelper.debugPrint("Connection", 0, "Connecting, attempt ");
        }
        
        try {
            SocketAddress address = new InetSocketAddress(host, port);
            m_socketChannel = SocketChannel.open(address);
            m_socket = m_socketChannel.socket();
            
            try {
                m_socket.setTcpNoDelay(true);
            } catch (SocketException e) {
                System.err.println("WARNING: Could not set TCP_NODELAY");
            }
        	
            m_outStream = new DataOutputStream(m_socket.getOutputStream());
            m_inStreamReader = new BufferedReader(new InputStreamReader(m_socket.getInputStream()));
        	
            if (HydnaDebug.HYDNADEBUG) {
                DebugHelper.debugPrint("Connection", 0, "Connected, sending HTTP upgrade request");
            }
        	
            m_connecting = false;
            m_connected = true;
        	
            connectHandler();
        } catch (UnresolvedAddressException e) {
            m_connecting = false;
            throw new ChannelError("The host \"" + host + "\" could not be resolved");
        } catch (IOException e) {
            m_connecting = false;
            throw new ChannelError("Could not connect to the host \"" + host + "\" on the port " + port);
        }
    }