Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1.         public void Init()
  2.         {
  3.             if (mClient != null)
  4.             {
  5.                 mClient.Close();
  6.                 mClient = null;
  7.             }
  8.             MoogPacketManager.Instance.Init();
  9.             Log.Instance.WriteInfo("Packet manager created");
  10.             mClient = new TcpClient();
  11.         }
  12.  
  13.         public void Reconnect()
  14.         {
  15.             if (mClient != null)
  16.             {
  17.                 mClient.Close();
  18.                 mClient = null;
  19.             }
  20.             mClient = new TcpClient();
  21.             Log.Instance.WriteInfo("Try to connect to " + mEndPoint);
  22.            
  23.             while (!mClient.Connected)
  24.             {
  25.                 try
  26.                 {
  27.                     mClient.Connect(mEndPoint);
  28.                     Log.Instance.WriteInfo("Connected = " + mClient.Connected);
  29.                 }
  30.                 catch (ArgumentNullException exception)
  31.                 {
  32.                     Log.Instance.WriteError(exception.Message);
  33.                     Thread.Sleep(mWaitTimeout);        
  34.                 }
  35.                 catch (ObjectDisposedException exception)
  36.                 {
  37.                     Log.Instance.WriteError(exception.Message);
  38.                     Thread.Sleep(mWaitTimeout);
  39.                 }
  40.                 catch (SocketException exception)
  41.                 {
  42.                     Log.Instance.WriteError(exception.Message);
  43.                     Thread.Sleep(mWaitTimeout);
  44.                 }
  45.             }
  46.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement