[RELEASE] My server files

Page 15 of 18 FirstFirst ... 5789101112131415161718 LastLast
Results 211 to 225 of 267
  1. #211
    Account Upgraded | Title Enabled! Ne[o]x is offline
    MemberRank
    Apr 2008 Join Date
    Romania | Baia MareLocation
    235Posts

    Re: [RELEASE] My server files

    Quote Originally Posted by zilvis89 View Post
    hey can anyone tell me why when i do everything good i enter IP i tried with my IP and with hamachi IP and with Local IP when i write ID , PW it says connection with the server interrupted?


    srry for my bad english
    do you put port 9958??? :poster_ss

  2. #212
    Apprentice fsockopen is offline
    MemberRank
    Jun 2008 Join Date
    12Posts

    Re: [RELEASE] My server files

    Put a timer on the action packet sit like foreach second you sit the stamina goes up by 20 or something.
    if you know a thing about what goes on under the hood and how a program works (aside from the code) and have studied the native windows dlls a bit, you should know that'll lead to utter disaster

    if you have 100 people on, that means you have (100+x) threads running, one for each player

    one timer per player for anything = not good

  3. #213
    Account Upgraded | Title Enabled! james1992_2006 is offline
    MemberRank
    Aug 2006 Join Date
    illlinoisLocation
    427Posts

    Re: [RELEASE] My server files

    Quote Originally Posted by fsockopen View Post
    if you know a thing about what goes on under the hood and how a program works (aside from the code) and have studied the native windows dlls a bit, you should know that'll lead to utter disaster

    if you have 100 people on, that means you have (100+x) threads running, one for each player

    one timer per player for anything = not good
    ahh u seem to be learning fast lol where r u learning from or who's teaching u? or do u got previous experience with coding or something? :P

  4. #214
    Account Upgraded | Title Enabled! Ultimatum is offline
    MemberRank
    Feb 2008 Join Date
    EnglandLocation
    334Posts

    Re: [RELEASE] My server files

    Does it matter? o.0 im not coding my own source so i don't need to make up perfect way's to get stamina working. Its only for LegendX ... just another member on rz =)

  5. #215
    Valued Member xEnt is offline
    MemberRank
    Nov 2006 Join Date
    100Posts

    Re: [RELEASE] My server files

    Also if he knew how to use a timer, he would not ask how to do it cause he would know some sort of way to get it working (even if its not the best way)

  6. #216
    Apprentice fsockopen is offline
    MemberRank
    Jun 2008 Join Date
    12Posts

    Re: [RELEASE] My server files

    ahh u seem to be learning fast lol where r u learning from or who's teaching u? or do u got previous experience with coding or something? :P
    google's teaching me (yes'sir'e) and ive had previous knowledge of how computers work due to my research.

    Does it matter? o.0 im not coding my own source so i don't need to make up perfect way's to get stamina working. Its only for LegendX ... just another member on rz =)
    yes it matters thats like telling someone the most painful way of doing something when there's a much less painful way

  7. #217
    Enthusiast Tarouka is offline
    MemberRank
    Oct 2006 Join Date
    27Posts

    Re: [RELEASE] My server files

    Then what are the alternative to timers? Thread.Sleep (apparently, that one sucks for being unaccurate)?

  8. #218
    Valued Member xEnt is offline
    MemberRank
    Nov 2006 Join Date
    100Posts

    Re: [RELEASE] My server files

    Never use Thread.Sleep because that stops every thread from running. Causes 100% CPU Usage and will freeze the entire server.

  9. #219
    Enthusiast Tarouka is offline
    MemberRank
    Oct 2006 Join Date
    27Posts

    Re: [RELEASE] My server files

    Then what should be used in multithreading to cause a SINGLE thread pause (or simply a timeout that does an action)?

  10. #220
    Apprentice fsockopen is offline
    MemberRank
    Jun 2008 Join Date
    12Posts

    Re: [RELEASE] My server files

    no, im not saying timers are bad, but limit them as much as you can;

    i prefer system.threading.timer it's nice and simple.

    one global timer handling all major things, it would preform a 'foreach' loop on the clients and append to all the minor things such as removing stigma, giving stam, etc.


    @ Thread.Sleep
    Thread.Sleep ONLY freezes the thread that it's in, for example;

    Code:
    Console.WriteLine("Hello");
    new Thread(new ThreadStart(
       delegate()
       {
           Thread.Sleep(1000);
           Console.WriteLine("Goodbye");
       }
    )).Start();
    Console.WriteLine("I have to go bye!");
    
    // output:
    
    // Hello
    // I have to go bye!
    // Goodbye

  11. #221
    Enthusiast Tarouka is offline
    MemberRank
    Oct 2006 Join Date
    27Posts

    Re: [RELEASE] My server files

    Quote Originally Posted by fsockopen View Post
    no, im not saying timers are bad, but limit them as much as you can;

    i prefer system.threading.timer it's nice and simple.

    one global timer handling all major things, it would preform a 'foreach' loop on the clients and append to all the minor things such as removing stigma, giving stam, etc.


    @ Thread.Sleep
    Thread.Sleep ONLY freezes the thread that it's in, for example;

    Code:
    Console.WriteLine("Hello");
    new Thread(new ThreadStart(
       delegate()
       {
           Thread.Sleep(1000);
           Console.WriteLine("Goodbye");
       }
    )).Start();
    Console.WriteLine("I have to go bye!");
    
    // output:
    
    // Hello
    // I have to go bye!
    // Goodbye
    Thanks for answering.

    I'll stick with timers for creating an AuthServer (socket check routine) as it seems to run smoother. I've seen somewhere that Thread.Sleep cause a large CPU usage (as you said xEnt) and that any other alternative possible should be used.

  12. #222
    Apprentice fsockopen is offline
    MemberRank
    Jun 2008 Join Date
    12Posts

    Re: [RELEASE] My server files

    don't use Thread.Sleep, do this

    Code:
    public static void Sleep(DateTime Time)
    {
        while (Time > DateTime.Now)
           Thread.Sleep(1);
    }
    what's your MSN? I can probably help you with more.

  13. #223
    Account Upgraded | Title Enabled! james1992_2006 is offline
    MemberRank
    Aug 2006 Join Date
    illlinoisLocation
    427Posts

    Re: [RELEASE] My server files

    Quote Originally Posted by fsockopen View Post
    google's teaching me (yes'sir'e) and ive had previous knowledge of how computers work due to my research.


    yes it matters thats like telling someone the most painful way of doing something when there's a much less painful way
    nice yea google can be ure best friend at times lol :P

  14. #224
    Enthusiast Tarouka is offline
    MemberRank
    Oct 2006 Join Date
    27Posts

    Re: [RELEASE] My server files

    Quote Originally Posted by fsockopen View Post
    Don't use Thread.Sleep, do this; (THIS IS FROM C++ UNTESTED IN C#) what's your MSN? I can probably help you with more.
    Code:
    public static void Sleep(DateTime Time)
    {
        while (Time > DateTime.Now)
           Thread.Sleep(1);
    }
    I adapted it for C#, it must work >.<

    Code:
    public static void Sleep(int millisecondsTimeout)
    {
        DateTime Time = DateTime.Now.AddMilliseconds(millisecondsTimeout);
        while (Time > DateTime.Now)
        {
             // In C#, nothing is needed to do a while loop
        }
    }
    Here is my routine to check the packets
    Code:
                    // Start Check monitor - Check every 3 seconds
                    Timer state_monitor = new Timer(StateCheck, null, 0, 3000);
    
    // ----------------------
            private void StateCheck(object data)
            {
                try
                {
                        Monitor.Enter(StateObjects);
                        for (int a = 0; a < StateObjects.Length; a++)
                        {
                            if (StateObjects[a].ID == -1 && (StateObjects[a].Connected == true || StateObjects[a].StateSocket != null))
                            {
                                DestroyState(StateObjects[a]);
                                continue;
                            }
                            if (StateObjects[a].StateSocket != null && StateObjects[a].TimeStamp.AddSeconds(30) < DateTime.Now)
                            {
                                StateObjects[a].StateSocket.BeginDisconnect(false, new AsyncCallback(Disconnect), StateObjects[a]);
                                Console.WriteLine(StateObjects[a].StateSocket.RemoteEndPoint + "/ID:" + a + " has been disconnected due to the 30 seconds timeout.");
                                continue;
                            }
                        }
                        Monitor.Exit(StateObjects);
    
                }
                catch (Exception e)
                {
                    Console.Beep();
                    Console.WriteLine("CRITICAL ERROR IN StateCheck()!!!\n" + e.ToString());
                }
            }
    As you can see, the timer is far more adapted than doing a while loop with Thread.Sleep(3000);

  15. #225
    Account Upgraded | Title Enabled! Ultimatum is offline
    MemberRank
    Feb 2008 Join Date
    EnglandLocation
    334Posts

    Re: [RELEASE] My server files

    Your point is, just because you have your own way of doing timers (system.threading.timer) that isn't the main scripts that cause disaster. People have there own way of doing things. There are alot more things in issue here, sockets, packet structure, memory Its a bit like the people that say C# could'nt be anything as good as c++ simply the main reason being c# is managed memory and c++ isn't, i think infamous proved them wrong =).
    Maybe that system.threading.timer is alot better, System.timers ill use, prolly use DateTime i dunno iv allready quit conquer xD.



Advertisement