Page 1 of 1

Add NetworkError() function

Posted: Tue Feb 18, 2025 12:16 am
by Quin
Currently, when checking the return value of ReceiveNetworkData() and similar, we get -1 if no more data can be read. However, this could be for any number of reasons, from that being all the data there is to a wouldblock. It's currently impossible to determine this with the Network library. mk-soft wrote the amazing NetworkTCP module, and it gives you different statuses when you receive data. My proposal for the PB stdlib, to avoid breaking old code, is a NetworkError() function, that could return e.g. #PB_Network_EndOfData, #PB_Network_WouldBlock, etc.

Re: Add NetworkError() function

Posted: Tue Feb 18, 2025 10:00 pm
by mk-soft
A GetNetworkError would be nice. I have something like this for Window and macOS. Only with Linux unfortunately only for the C-backend.

There is no such thing as EndOfData or WouldBlock with TCP/IP.
This has to be programmed in the application layer itself as with my module or as with Modbus/TCP.