public void Connect(string ip, int port)
 {
     try
     {
         Logx.Log("net", "start connect ...");
         IPAddress  mIp          = IPAddress.Parse(ip);
         IPEndPoint ip_end_point = new IPEndPoint(mIp, port);
         netSocket.BeginConnect(ip_end_point, OnConnectCallback, netSocket);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         //ChangeToCloseState();
     }
 }
    void OnConnectCallback(IAsyncResult ar)
    {
        var s = (Socket)ar.AsyncState;

        Logx.Log("net", "OnConnectCallback : on connect : " + s.Connected);
        if (s.Connected)
        {
            netState = NetState.Connect;
            s.EndConnect(ar);

            s.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(OnReceiveCallback), s);
        }
        else
        {
            Logx.LogWarning("OnConnectCallback : the socket connect fail");
        }
        //heartBeatService.Start();
        bool isSuccessConnect = netSocket.Connected;

        connectAction?.Invoke(isSuccessConnect);
    }
 public void OnConnectToLoginServerFinish(bool isSuccess)
 {
     Logx.Log("net", "NetworkManager : OnConnectToLoginServerFinish : " + isSuccess);
 }