ReceiveNetworkData issue

Just starting out? Need help? Post your questions and find answers here.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I still suspect the problem with your code is that you have a Delay(1) somewhere that triggers even if NetworkServerEvent() or WindowEvent() returns something else than 0. Removing that should fix the performance problem. (Or you may have a delay in the sending code, though that should be more obvious to spot.)

Alternatively, it may be easier and more reliable to put the networking code in a thread. That way there may be less clutter. In my opinion all network code should go in a thread because if it takes longer than normal (may happen on network failures) the user interface won't hang.
Jordi
User
User
Posts: 53
Joined: Sat Apr 26, 2003 10:19 am
Location: Cosmos

Post by Jordi »

After all I have found a misstake, you are right Trond! a delay(1) is in between spaghetties. Simplifying:

Code: Select all

Repeat
        EventServer = NetworkServerEvent()
        If EventServer
           Select EventoServidor
   ...
           EndSelect
        EndIf
        Delay(1)
Until Quit = 1
If I delete Delay (1) I obtain a 100% used CPU but with below code (simplified) all seems ok:

Code: Select all

Repeat
        EventServer = NetworkServerEvent()
        If EventServer
           Select EventoServidor
   ...
           EndSelect
        Else
           Delay(1)
        EndIf
Until Quit = 1
Thanks to all for your help, please forgive me for this stupid post...

Next step increase the length of data send up to MTU length, compressing and crypting streams and put the networking routines inside in a thread. Job for a while.

Thks again Trond, Mahan and Thalius![/quote]
Post Reply