UDP Local Network Short Text Sending (All OS)

Share your advanced PureBasic knowledge/code with the community.
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: UDP Local Network Short Text Sending (All OS)

Post by RichAlgeni »

The packets should be delivered whole, but I don't think you can count on only getting just one packet per read. You are using start and end bytes, so that should help distinguish the packets just in case. One more thing you could do is add a length in bytes field, or pad out the packet to a consistent size.

Just a couple of thoughts.
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: UDP Local Network Short Text Sending (All OS)

Post by mk-soft »

RichAlgeni wrote: Fri Sep 29, 2023 8:41 pm The packets should be delivered whole, but I don't think you can count on only getting just one packet per read. You are using start and end bytes, so that should help distinguish the packets just in case. One more thing you could do is add a length in bytes field, or pad out the packet to a consistent size.

Just a couple of thoughts.
Not required here, as the receive data is separated by start and end characters, regardless of how it arrives.
Otherwise see module NetworkTCP
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: UDP Local Network Short Text Sending (All OS)

Post by skinkairewalker »

I'm using this client to test the amount of load the server is supporting...
every 10ms, the 300 clients send a message to the server, until it supports it... but if I increase this number to 350, 400, n+...
It is already overloaded and clients are no longer able to perform basic functions, such as logging in for example.
Could it be a limitation of my hardware?
Or does the server really have this limitation on the number of connections per second?

start_udpclient.bat

Code: Select all

@echo off
set "executable=client_udp.exe"

for /l %%x in (1,1,300) do (
  start "" "%executable%"
)

exit
udpclient.pb

Code: Select all

Port = 6833
*Buffer = AllocateMemory(2048)

evnt.i = 0
ConnectionID = OpenNetworkConnection("127.0.0.1", Port,#PB_Network_UDP)
If ConnectionID
  OpenConsole("pain test")
  Repeat
    
    evnt = NetworkClientEvent(ConnectionID)
    
    Select evnt

        Case #PB_NetworkEvent_Data
          ReceiveNetworkData(ConnectionID, *Buffer, 2048)
          PrintN("String: "+PeekS(*Buffer, -1, #PB_UTF8|#PB_ByteLength))

    EndSelect    
    
    SendNetworkString(ConnectionID, #STX$ + "LifeTrigger udp new 10ms" + #ETX$, #PB_UTF8)
    Delay(10)
    
  ForEver
  ;CloseNetworkConnection(ConnectionID)
Else
  MessageRequester("PureBasic - Client", "Can't find the server (Is it launched ?).", 0)
EndIf

End
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: UDP Local Network Short Text Sending (All OS)

Post by mk-soft »

Calculate the data load per second.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: UDP Local Network Short Text Sending (All OS)

Post by skinkairewalker »

How would I do this?
because in theory what would be the limitation?
number of available ports, hardware, limitation of the socket itself...
I can't find a way... xD


A potential solution would be to create a processing queue on the server??
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: UDP Local Network Short Text Sending (All OS)

Post by mk-soft »

Windows is not a real-time operating system.
In addition, many other protocols run over the network card that the operating system must process and distribute.
Then the server must also correctly allocate the 300 clients and store and report the 30000 received data per second.
So the server processes every 0,033 milliseconds a packet.
In your example as a local host, that is over 60000 UDP packets per second.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: UDP Local Network Short Text Sending (All OS)

Post by skinkairewalker »

What do you advise doing to make the server handle more than 10,000 connected users in an MMORPG Or applications that need to be critical with a high message demand??
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: UDP Local Network Short Text Sending (All OS)

Post by mk-soft »

So it's not so easy with one server with Purebasic.
For this you need several servers with multiserver management with load distribution.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: UDP Local Network Short Text Sending (All OS)

Post by skinkairewalker »

Would creating server instances on several different ports as if they were "channels" be a temporary solution?

and how would you measure the message load per second or millisecond?
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: UDP Local Network Short Text Sending (All OS)

Post by mk-soft »

I am not a gamer server high performans programmer.
Besides, this is the wrong place to clarify this.
Please create a new request.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: UDP Local Network Short Text Sending (All OS)

Post by skinkairewalker »

I will do that, thank you very much!
Post Reply