/// <summary> /// 建立连接 /// </summary> /// <param name="ip">ip字符</param> /// <param name="port">port字符</param> /// <returns>连接状态</returns> public int EstablishConnection() { IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("172.16.18.171"), Convert.ToInt32("3000")); HeartTimerStart(); if (tcpSocket.ConnectServer(ipe) == 0) { receiveThread.Start(); SendStart(); online = true; Log.log.Debug("EstablishConnection success"); return(0); } Log.log.Debug("EstablishConnection fail"); return(-1); }
/// <summary> /// 建立一次连接 /// </summary> /// <param name="ip">ip字符</param> /// <param name="port">port字符</param> /// <returns>连接状态</returns> private int EstablishConnection() { IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("172.16.18.171"), Convert.ToInt32("3000")); Log.log.Info("Try to establish connection"); if (tcpSocket.ConnectServer(ipe) == 0) { RecHeartTimerStart(); receiveThread.Start(); SendStart(); Thread.Sleep(100); if (online == false) { Log.log.Info("Connection fail"); return(-1); } SendHeartTimerStart(); Log.log.Info("Establish connection success"); return(0); } Log.log.Info("Unable Connect with device"); return(-1); }