TSocket Question
Posted: Thu Oct 04, 2012 11:20 am
Hi,
I'm trying to connect to a windows socket & although my test routine is working, I dont seem to be able to check if i'm connected.
I have a public variable called lConnected that is initially set to .F. - this is set to true in bConnect, but when i try to reference it, it always returns .f. - the senddata & getdata routines all work fine.
Is there a better way to detect if i'm connected?
Thanks in advance
Pete
I'm trying to connect to a windows socket & although my test routine is working, I dont seem to be able to check if i'm connected.
I have a public variable called lConnected that is initially set to .F. - this is set to true in bConnect, but when i try to reference it, it always returns .f. - the senddata & getdata routines all work fine.
Is there a better way to detect if i'm connected?
Code: Select all
STATIC FUNCTION SocketTest
LOCAL mTimer := 0
PRIVATE oSocket := TSocket():New(8888)
oSocket:bRead := { | oSocket | Msginfo( oSocket:GetData() ) }
oSocket:bConnect := { || lConnected := .T. }
oSocket:Connect( "192.168.69.92" ) // use the server IP address here
DO WHILE !lConnected .AND. mTimer < 999999
mTimer++
ENDDO
IF lConnected
oSocket:SendData( "Hello" )
ThreadSleep(1000)
IF MsgYesNo("Quit?")
RETU NIL
ENDIF
ELSE
? "Not Connected"
ENDIF
RETURN NIL
Pete