Beispiel #1
0
 /// <summary>
 /// 连接
 /// </summary>
 /// <param name="timeOut"></param>
 /// <returns></returns>
 public bool Connect(int timeOut = 10000)
 {
     if (client != null)
     {
         client.Disconnect();
         client.Dispose();
     }
     client           = new TCPClient();
     client.LocalHost = LocalHost;
     client.LocalPort = LocalPort;
     client.Host      = Host;
     client.Port      = Port;
     if (client.Connect(timeOut) == SocketError.Success)
     {
         client.ReceiveClientData += Client_ReceiveClientData;
         StartHeart();
         LocalHost = client.LocalHost;
         LocalPort = client.LocalPort;
         return(true);
     }
     return(false);
 }