Page 2 of 4
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Mon Mar 31, 2025 3:43 pm
by Quin
idle wrote: Fri Mar 28, 2025 8:42 am
I don't understand why your having trouble with the connection, it will just fail and return the error
I am using the functions in the server for both server and client via the reverse proxy and its not crashing
That's super interesting, I've had it crash for both my client and server. Using IsSocketAvailable provided by another forum member fixes it on the client side, but it doesn't work on the server side. The line that's failing is always:
Code: Select all
SendLen = SendNetworkData(ClientID, *Buffer + TotalSent, TryLen)
Saying the specified connection ID is null.
IMO this should not be a crash on the PB side, that's frankly absurd. Just return a suitable error value. Here's hoping for NetworkError() in 6.30

Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Mon Mar 31, 2025 7:18 pm
by idle
I think you'll find it's how your using them is the problem
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Mon Mar 31, 2025 8:13 pm
by User_Russian
I see that they are improving the network functions here.
Does anyone have an analogue of function OpenNetworkConnection() with non-blocking mode for TCP? I have it for older versions of PB (without IPv6) and only for Windows.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Mon Mar 31, 2025 8:59 pm
by Quin
idle wrote: Mon Mar 31, 2025 7:18 pm
I think you'll find it's how your using them is the problem
Would you mind expanding on what you mean here? How is it possible to use these functions "incorrectly"?
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Tue Apr 01, 2025 6:40 am
by idle
I don't know how you're using them but the functions aren't the problem here. If you need some help ask a question If you want ro see how I'm using them look at the source of atomic webserver.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Tue Apr 01, 2025 1:09 pm
by Quin
I did ask a question, how to check for a valid client ID. The IsSocketAvailable procedure seemed to work on the client-side but not on the server, it would always return false for any client.
I really don't see how a PB function crashing in your procedure could be my fault, but I also see how it's definitely not yours, so I'll just hope for a native NetworkError function in the meantime.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Tue Apr 01, 2025 9:16 pm
by idle
Considering both functions are only used in the circumstances of network events connect or event data the question is how do they fail. In both cases you have valid connections.
I agree it would be nice to have a test to see if the socket is open but it's not so easy.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Tue Apr 01, 2025 10:55 pm
by Quin
idle wrote: Tue Apr 01, 2025 9:16 pm
Considering both functions are only used in the circumstances of network events connect or event data the question is how do they fail. In both cases you have valid connections.
no, you don't.
What if the server drops? What if the user loses internet connectivity? Etc etc? These are things I see happen in the real world in my app, and when it does, sometimes invalid client ID's get passed to this function. PB definitely shouldn't just barf like this and crash, though.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Thu Apr 03, 2025 12:05 am
by idle
Quin wrote: Tue Apr 01, 2025 10:55 pm
idle wrote: Tue Apr 01, 2025 9:16 pm
Considering both functions are only used in the circumstances of network events connect or event data the question is how do they fail. In both cases you have valid connections.
no, you don't.
What if the server drops? What if the user loses internet connectivity? Etc etc? These are things I see happen in the real world in my app, and when it does, sometimes invalid client ID's get passed to this function. PB definitely shouldn't just barf like this and crash, though.
if the server drops while your in a send or receive it will detect it but it won't if your missing a #PB_NetworkEvent_Disconnect event. If your still having issues ask a question with a code example of your client and server.
Network code can be frustrating to debug, it should be as simple as writing to a file but it's not.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Fri Apr 11, 2025 11:42 pm
by Quin
Idle,
You're absolutely right, it was completely a bug on my side. I wasn't assigning my users their correct client IDs!

Your functions work great, thanks for sharing!
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Fri Apr 11, 2025 11:49 pm
by idle
Quin wrote: Fri Apr 11, 2025 11:42 pm
Idle,
You're absolutely right, it was completely a bug on my side. I wasn't assigning my users their correct client IDs!

Your functions work great, thanks for sharing!
Glad you found the bug.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Wed Apr 30, 2025 5:38 pm
by Quin
Hey Idle,
Can't use these functions on Linux...
With the asm backend I get:
Line 110 - __errno_location() is not a function, array, list, map or macro.
and with the C backend, I get:
Line 118 - Constant not found: #WSA_IO_INCOMPLETE.
It's maybe obvious from the errors themselves, but my line numbers are different, so it's in the NetworkErrorContinue function.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Wed Apr 30, 2025 10:09 pm
by idle
I don't know if there are equivalents to #WSA_IO_INCOMPLETE or #WSA_IO_PENDING on linux
they're currently out of the compiler if and as for the errno it probably needs an ImportC like
Code: Select all
ImportC ""
__errno_location()
EndImport
error = PeekI(__errno_location())
I'll be switching over to Linux in the next couple of days.
Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Wed Apr 30, 2025 10:31 pm
by Quin
Idle,
That import didn't work unfortunately, but I'm normally using the C backend, so it doesn't bother me too much.
As for the constants, I think you'd want something like EAGAIN or EWOULDBLOCK, but you're far more knowledgeable about this than me, so I'll await your thoughts once trying linux

Re: Wrappers to do full sendNetworkData and ReceiveNetworkData
Posted: Mon May 05, 2025 4:09 am
by Quin
Hey Idle,
Any updates? I'd really like to run my server on Linux

Thanks for all your ggreat work and your talent!