NetWork questions

Just starting out? Need help? Post your questions and find answers here.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 551
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

NetWork questions

Post by minimy »

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!
If translation=Error: reply="Sorry, Im Spanish": Endif
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: NetWork questions

Post by jassing »

the id's are generated automatically.
Did you see the examples networkClient.pb and networkServer.pb?
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: NetWork questions

Post by idle »

callingbelieve wrote: Wed Jun 12, 2024 8:32 am
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
Client 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)

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.
And that's what you call an AI chatbot!
User avatar
minimy
Enthusiast
Enthusiast
Posts: 551
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: NetWork questions

Post by minimy »

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!!
If translation=Error: reply="Sorry, Im Spanish": Endif
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: NetWork questions

Post by Quin »

minimy wrote: Mon Jun 10, 2024 7:19 pm Will be nice have pb examples in next versions.
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? :mrgreen:
User avatar
mk-soft
Always Here
Always Here
Posts: 6201
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: NetWork questions

Post by mk-soft »

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.
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
Post Reply