Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- Cli.Connect(this.Server, this.Port);
- //Handle good connection
- NS = new NetworkStream(Cli);
- if (Handshake())
- {
- Log("Looks as if the handshake was a Successes!");
- //ClientConnectionStatus(ConnectionStatus.ConnectionSuccessful);
- Log("Starting The Listen Thread");
- Runner = new Thread(() => {
- Log("Runner... running lol");
- byte pid;
- try
- {
- while (Cli.Connected && (int)(pid = (byte)NS.ReadByte()) != 255)
- {
- PacketReceived((PacketType)pid);
- NS.WriteByte((byte)PacketType.KeepAlive);
- NS.Flush();
- }
- }
- catch (Exception ex)
- {
- Log("Packet Listen Failed " + ex.Message);
- throw new Exception("Listen ERROR ", ex);
- }
- Dissconnect("Disconnect");
- });
- Runner.Start();
- }
- }
- catch(Exception)
- {
- if (!Cli.Connected)
- Log("ERR: TCP CLient Not Connected");
- }
Add Comment
Please, Sign In to add comment