PB 4.30 - CloseNetworkConnection(clientID) bug?
Posted: Fri May 08, 2009 6:45 pm
Hello!
I've been messing around with network connections and threads making some FTP like program. And I've noticed that if I in my thread tries to close a connection that has already been closed by the client then my program will get an invalid memory access on the next "Select NetworkServerEvent()". I have really confirmed this with several tests (but I'm not able to put a snippet here yet).
So to fix it this is what I had to do:
I also tried to check if it was still open with ConnectionID(clientID) but that would cause problems too. So what I suggest is just a command called IsConnection(clientID). Or that CloseNetworkConnection(clientID) should not cause trouble if the connection is already closed.
EDIT:
Move my thread all you want, but I still think this code is strange:
http://www.purebasic.fr/english/viewtop ... 524#286524
Why only IMA when used in the thread?
I've been messing around with network connections and threads making some FTP like program. And I've noticed that if I in my thread tries to close a connection that has already been closed by the client then my program will get an invalid memory access on the next "Select NetworkServerEvent()". I have really confirmed this with several tests (but I'm not able to put a snippet here yet).
So to fix it this is what I had to do:
Code: Select all
If GetClientPort(clientID) ;is it still open?
CloseNetworkConnection(clientID)
EndIf
EDIT:
Move my thread all you want, but I still think this code is strange:
http://www.purebasic.fr/english/viewtop ... 524#286524
Why only IMA when used in the thread?