TSocket Question

Post Reply
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

TSocket Question

Post by PeterHarmes »

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?

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

 
Thanks in advance

Pete
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: TSocket Question

Post by PeterHarmes »

Hi,

Anyone have any ideas?

Best regards,

Pete
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TSocket Question

Post by Antonio Linares »

Peter,

FWH Class TSocket requires that there is a defined main window. There is no need to wait in a loop.

Please review FWH\samples\sockcli.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
FiveWiDi
Posts: 910
Joined: Mon Oct 10, 2005 2:38 pm

Re: TSocket Question

Post by FiveWiDi »

Antonio Linares wrote:Peter,

FWH Class TSocket requires that there is a defined main window. There is no need to wait in a loop.

Please review FWH\samples\sockcli.prg
Hola Antonio,

Eso que comentas de la clase TSocket es aplicable a la clase HB_WhatsApp?

Para enviar WhastApp con la clase que menciono, debería funcionar desde un entorno MDI?

Saludos,
Carlos G.
Un Saludo
Carlos G.

FiveWin 19.06 + Harbour 3.2, BCC 7 Windows 10
Post Reply