Guest User

Untitled

a guest
Oct 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. try
  2. {
  3. Cli.Connect(this.Server, this.Port);
  4. //Handle good connection
  5.  
  6. NS = new NetworkStream(Cli);
  7.                                     if (Handshake())
  8.                                     {
  9.                                         Log("Looks as if the handshake was a Successes!");
  10.                                         //ClientConnectionStatus(ConnectionStatus.ConnectionSuccessful);
  11.                                         Log("Starting The Listen Thread");
  12.                                         Runner = new Thread(() => {
  13.                                             Log("Runner... running lol");
  14.                                             byte pid;
  15.                                             try
  16.                                             {
  17.                                                 while (Cli.Connected && (int)(pid = (byte)NS.ReadByte()) != 255)
  18.                                                 {
  19.                                                     PacketReceived((PacketType)pid);
  20.                                                     NS.WriteByte((byte)PacketType.KeepAlive);
  21.                                                     NS.Flush();
  22.                                                 }
  23.                                             }
  24.                                             catch (Exception ex)
  25.                                             {
  26.                                                 Log("Packet Listen Failed " + ex.Message);
  27.                                                 throw new Exception("Listen ERROR ", ex);
  28.                                             }
  29.                                             Dissconnect("Disconnect");
  30.                                         });
  31.                                         Runner.Start();
  32.                                     }
  33. }
  34. catch(Exception)
  35. {
  36. if (!Cli.Connected)
  37.    Log("ERR: TCP CLient Not Connected");
  38. }
Add Comment
Please, Sign In to add comment