Page 1 of 1

Send/ReceiveNetworkData(), ConnectionID()... crash prevention

Posted: Fri Mar 28, 2025 4:24 pm
by tatanas
Hi,

I'm curious about the behaviour of those network functions when the connection parameter is not valid anymore.
I'm working on a TCP client/server (=~ 250 simultaneous connected clients) and if a client disconnects when a working thread try to send data to it, crash happens. I have to check everytime the accessibility of the socket with a non PB native function.

If I compare with the win32 send_() function, this last one doesn't crash if the socket handle is obsolete.
Is there a technical reason why those functions crash with a "invalid memory access" ?

Could you enhance those functions so that they will accept an obsolete socket handle and return an new error value ?

Thanks for your time.

Re: Send/ReceiveNetworkData(), ConnectionID()... crash prevention

Posted: Fri Mar 28, 2025 4:37 pm
by Quin
tatanas wrote: Fri Mar 28, 2025 4:24 pm Could you enhance those function so that they will accept an obsolete socket handle and return an new error value ?
+100

Re: Send/ReceiveNetworkData(), ConnectionID()... crash prevention

Posted: Wed Apr 16, 2025 9:34 pm
by swhite
I use the TCP sockets a lot and returning an error message rather than crashing would be much better and allow you to handle the situation cleanly. The alternative would be something like IsConnection() so that it could be used like Isdatabase() to determine if the connection is valid.

Simon