Using createNetworkServer I see that to send messages from the server to the client I use its clientID=EventClient(), to do it the other way around, on the client I have to put the local client ID. (not obvious but work)
All work good with TCP.
The questions are:
To send from client A to client B what do I need to put as an ID?. I did with server ClientID sended from server to the other clients. Is the right way?
As it connects UDP, it is supposed that by putting the IP the packets are sent to all users, but none arrive, should I use a special port so that they are not blocked?
Will be nice have pb examples in next versions.
Thanks for replys and time!
NetWork questions
NetWork questions
If translation=Error: reply="Sorry, Im Spanish": Endif
Re: NetWork questions
the id's are generated automatically.
Did you see the examples networkClient.pb and networkServer.pb?
Did you see the examples networkClient.pb and networkServer.pb?
Re: NetWork questions
And that's what you call an AI chatbot!callingbelieve wrote: Wed Jun 12, 2024 8:32 amClient A sends a message to the server, indicating that the message is intended for Client B. The message includes Client B's ID and the content of the message. Example: server.send(ClientB_ID, message_from_A)minimy wrote: Mon Jun 10, 2024 7:19 pm Using createNetworkServer I see that to send messages from the server to the client I use its clientID=EventClient(), to do it the other way around, on the client I have to put the local client ID. (not obvious but work)
All work good with TCP.
The questions are:
To send from client A to client B what do I need to put as an ID?. I did with server ClientID sended from server to the other clients. Is the right way?
As it connects UDP, it is supposed that by putting the IP the packets are sent to all users, but none arrive, should I use a special port so that they are not blocked?
Will be nice have pb examples in next versions.
Thanks for replys and time!scratch geometry dash
Server Forwards the Message to Client B:
The server receives the message from Client A.
The server then forwards the message to Client B using Client B's ID.
Example: clientB_ID = getClientID("ClientB")
send(clientB_ID, message_from_A)
UDP communication is connectionless and does not inherently guarantee message delivery. To ensure messages are routed correctly:
Use Server as a Relay: Even with UDP, use the server as a relay to manage client connections and IDs.
Port Handling: Ensure all clients are listening on the correct UDP ports and that your network configuration (e.g., firewall rules) allows UDP traffic on these ports.
Re: NetWork questions
Hello Jassing, examples are unidirectional no explain send in both directions, but no problem i solved by my self. Thanks anyway.
Hello Idle, thanks. Then in the server side the right way is send to clients a list with all the conections, is right?
On UDP connections, the maximum 'Length' is 2048. On TCP connections, the maximum 'Length' is 65536
Other question is data control, with tcp in every packet is include 20bytes of control, the 20bytes are included in the maximun packet size or the maximun send size is 65536-20? (using udp is only 8bytes 2048-8)
Will be nice a command like getClients() to get a list wit all conections. Ok, i can make with code but will be nice for forever noobs like me, hehe
Thanks to both for help, have a nice day!!
Hello Idle, thanks. Then in the server side the right way is send to clients a list with all the conections, is right?
On UDP connections, the maximum 'Length' is 2048. On TCP connections, the maximum 'Length' is 65536
Other question is data control, with tcp in every packet is include 20bytes of control, the 20bytes are included in the maximun packet size or the maximun send size is 65536-20? (using udp is only 8bytes 2048-8)
Will be nice a command like getClients() to get a list wit all conections. Ok, i can make with code but will be nice for forever noobs like me, hehe
Thanks to both for help, have a nice day!!
If translation=Error: reply="Sorry, Im Spanish": Endif
Re: NetWork questions
Fully agreed; PB's networking layer could do with some love, at the very least in the examples. It's supposed to be a beginner-friendly language and yet it's not even discussed how to continuously read from a socket until you get a full packet?

Re: NetWork questions
There, that would be nice ...
So I wouldn't have to keep repeating that SendNetWorkData doesn't send the data, but transfers the data to the OS send buffer.
And that ReceiveNetworkData does not receive the data, but reads out the OS receive buffer.
So I wouldn't have to keep repeating that SendNetWorkData doesn't send the data, but transfers the data to the OS send buffer.
And that ReceiveNetworkData does not receive the data, but reads out the OS receive buffer.
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
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive