public void Connect(IPAddress ipAddress, int port) { if (m_Socket != null) { Close(); } m_Socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); try { m_Socket.BeginConnect(ipAddress, port, ConnectCallBack, m_Socket); } catch (Exception e) { if (m_Handler != null) { m_Handler.OnExceptionCaught(this, e); } } }