I wrote an enhanced SendNetworkData function that checks if all data was sent. it receives a packet that should have a header containig the packet length in 8 bytes followed by packet type in 1 byte then the payload.
it's been months i'm trying to figure out a problem : once in a while, i get [ERROR] Invalid memory access. (read error at address 3473458).
I can't figure out what conditions raise this error.
is there a way to handle this error or a sort of on "error resume next"
Here is the function :
Code: Select all
Procedure SendNetworkData2(ConnectionID.l, *b)
Protected DataSent.q = 0, TotaltDataSent.q = 0
Protected length.q = PeekQ(*b)
Protected type = PeekA(*b + 8)
Repeat
DataSent = SendNetworkData(ConnectionID, *b + TotaltDataSent, length - TotaltDataSent)
If DataSent > 0
TotaltDataSent + DataSent
EndIf
Delay(1)
Until TotaltDataSent = Length
FreeMemory(*b)
ProcedureReturn TotaltDataSent
EndProcedure