Page 1 of 1

Detect invalid Connection ID prior

Posted: Wed Dec 25, 2024 11:22 pm
by danny88
hello

look at this code :

Code: Select all

ClientID = 750154536	;Random invalid Connection ID

sent = SendNetworkString(ClientID, "Hello"); Returns Invalid memory accesss
How to check if Connection ID is valid before using it

Re: Detect invalid Connection ID prior

Posted: Thu Dec 26, 2024 12:30 am
by infratec
TCP or UDP ?
In UDP this should not happen.

Do you send data regulary or with pauses? (How long are the pauses?)

In general you can not detect this with PB internal commands directly.
You can try to keep the connnection alive to avoid this, by sending periodically 'keep-alive' packets.

I'm not sure if you can detect via low level functions if a connection which was opened by PB can be checked.

Re: Detect invalid Connection ID prior

Posted: Thu Dec 26, 2024 8:12 am
by danny88
TCP.
I send packets periodically
There are many clients that connect and disconnect randomly.

So it may happen that the client is connected when the decision is taken to send it a packet but then discconnects just before the packet is sent

Re: Detect invalid Connection ID prior

Posted: Thu Dec 26, 2024 10:59 am
by infratec
Do you detect the disconnect event?

But ... in general I would say it is a PB bug.
The procedure should return -1 and should not generate an IMA.

Re: Detect invalid Connection ID prior

Posted: Thu Dec 26, 2024 12:56 pm
by danny88
yeah that's also what I think.
any idea how to overcome it ?

Re: Detect invalid Connection ID prior

Posted: Thu Dec 26, 2024 5:42 pm
by Gérard

Code: Select all

OnErrorGoto(?ErrorHandler)

ClientID = 750154536	;Random invalid Connection ID

sent = SendNetworkString(ClientID, "Hello"); Returns Invalid memory accesss

ErrorHandler:
;Error handling

Re: Detect invalid Connection ID prior

Posted: Fri Dec 27, 2024 10:35 am
by infratec
infratec wrote: Thu Dec 26, 2024 10:59 am Do you detect the disconnect event?
Then you have to close the connection.