EventClient([Server]) + other network improvements

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
benubi
Enthusiast
Enthusiast
Posts: 215
Joined: Tue Mar 29, 2005 4:01 pm

EventClient([Server]) + other network improvements

Post by benubi »

Hello

An additional optional parameter for the EventClient() function would make it possible to do real multi threaded networking. For now the only way I found to make it work (relatively unstable) is by using a shared thread for all the network operation or using that thread to dispatch network messages to worker threads; and I use a lot of Lock/Unlock each time when checking for events.

Code: Select all

EventClient([Server])
This additional parameter would make it easier to dispatch and/or use dedicated worker threads (I believe), and the way I write ( :oops: ) make it more stable. IDK if I'm doing it right anyway, but it's a bottleneck the way it's now, isn't it?


Also useful to avoid "unnecessary" wrapping or for ease of use would be:

Code: Select all

ClientIPVersion(Client) ; returns 4 or 6 or 0 (on error)
ServerIPVersion(Server) ;"
or perhaps even better

Code: Select all

ClientFlags(Client) ; returns the flags in #PB_Network_* constants format = IP Version + Used Protocol + X
ServerFlags(Server) ; "
And perhaps

Code: Select all

ServerBindedIP(Server) ; returns the indicated string
ServerPort(Server) ; the port you opened the server on
But these can also be made by wrapping, so it's not important or as necessary as EventClient().


Dear Santa, it would be fancy to set the socket options without going through the API. (all those TCP/UDP/timeout socket options)

Finally I have the impression that in old PB versions it was possible to do an UDP broadcast on LAN (255.255.255.255) but now it will fail to open an UDP socket with that broadcast address. Those types of broadcasts can be useful for searching LAN games or things like DHCP servers to get retrieve information like subnet mask or http proxy and more. Those addresses are reserved and not transmitted via routers except when explicitly configured for it to be a bridge, and normally backbone internet routers shouldn't relay or respond to these except when tunneled outside their knowledge like in a VPN (in which case they don't know about the content).