about ConnectionID() function bug

Just starting out? Need help? Post your questions and find answers here.
shu7734
User
User
Posts: 30
Joined: Thu May 15, 2008 5:53 am

about ConnectionID() function bug

Post by shu7734 »

InitNetwork()
Connection1=0
Debug ConnectionID(Connection1)

F5 run the code

[ERROR] Invalid memory access. (Read error at address 0)
Win7X64 Purebasic5.22x86DEMO
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: about ConnectionID() function bug

Post by netmaestro »

It should give the compiler error "The specified connection is not initialized" to be consistent with other PB objects. The IMA is a bug.
BERESHEIT
shu7734
User
User
Posts: 30
Joined: Thu May 15, 2008 5:53 am

Re: about ConnectionID() function bug

Post by shu7734 »

My Environment

PureBasic 4.51 (Windows - x86)
Windows Server 2003 R2 MSDN Sp2
Win7X64 Purebasic5.22x86DEMO
shu7734
User
User
Posts: 30
Joined: Thu May 15, 2008 5:53 am

Re: about ConnectionID() function bug

Post by shu7734 »

the Connection1 is a object?

is not a long value?
Win7X64 Purebasic5.22x86DEMO
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: about ConnectionID() function bug

Post by netmaestro »

The ConnectionID command expects a pointer to a valid connection object. Something other than that is received. A descriptive compiler error message is the correct response, an IMA is not. Fred or Freak will fix it.
BERESHEIT
freak
PureBasic Team
PureBasic Team
Posts: 5944
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: about ConnectionID() function bug

Post by freak »

The debugger cannot validate if a given value is a valid connection. It doesn't have that information. It could only catch the 0 value but thats not that helpful imho.

Anyway, the memory access error clearly tells you that something is wrong, so the debugger did at least part of its job :D
quidquid Latine dictum sit altum videtur
shu7734
User
User
Posts: 30
Joined: Thu May 15, 2008 5:53 am

Re: about ConnectionID() function bug

Post by shu7734 »

because i used the funtion on DLL
compiler cann't find the error

Procedure Thread(*Parameters.l)
Sleep_(120000)
Connection=0
SendFileMode=*Parameters
If SendFileMode=0
While Connection=0
Sleep_(30000)
Connection=OpenNetworkConnection("127.0.0.1",80,#PB_Network_TCP)
i=i+1
If i>10
SendFileMode=1
Break
EndIf
Wend
EndIf

If SendFileMode=1
If ConnectionID(Connection)
CloseNetworkConnection(Connection)
EndIf
EndIf

EndProcedure

ProcedureDLL DllMain()
InitNetwork()
CreateThread(@Thread(),1)
Sleep_(1000000)
EndProcedure
Win7X64 Purebasic5.22x86DEMO
freak
PureBasic Team
PureBasic Team
Posts: 5944
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: about ConnectionID() function bug

Post by freak »

The ConnectionID() command only works on a valid connection. You cannot use it like this.
quidquid Latine dictum sit altum videtur
Post Reply