Author Topic: TNet/RFC Debugging  (Read 10430 times)

gg67

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 66
    • View Profile
Re: TNet/RFC Debugging
« Reply #30 on: July 23, 2014, 09:17:06 PM »
I started working on this, but am having issues getting a basic connection going. It connects and then times out. Here's where I'm at:

  1. public class AdminMain
  2. {
  3.     static Thread mThread;
  4.     static GameClient mClient;
  5.  
  6.         /// <summary>
  7.         /// Application entry point -- parse the parameters.
  8.         /// </summary>
  9.  
  10.         static int Main (string[] args)
  11.         {
  12.         mClient = new GameClient();
  13.         TcpProtocol tcp = new TcpProtocol();
  14.         IPEndPoint endPoint = TNet.Tools.ResolveEndPoint("127.0.0.1", 5127);
  15.         tcp.Connect(endPoint);
  16.  
  17.  
  18.         mThread = new Thread(ThreadFunction);
  19.         mThread.Start();
  20.  
  21.         return 0;
  22.         }
  23.  
  24.     static void ThreadFunction()
  25.     {
  26.         for (; ; )
  27.         {
  28.             mClient.ProcessPackets();
  29.         }
  30.     }
  31. }
  32.  
  33.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNet/RFC Debugging
« Reply #31 on: July 23, 2014, 09:47:04 PM »
You should never have an endless loop like that. You need to add a Thread.Sleep in there or you will be completely eating up all your CPU cycles. Your Main function also exits right away, resulting in your application effectively shutting down. Have a look at the stand-alone server example that comes with TNet. It has a main function, and it enters an input loop there, thus preventing the application from terminating.