FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TSocket Question
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
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?

Code (fw): Select all Collapse
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
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: TSocket Question
Posted: Wed Oct 24, 2012 08:21 AM

Hi,

Anyone have any ideas?

Best regards,

Pete

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TSocket Question
Posted: Wed Oct 24, 2012 11:02 AM

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
Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: TSocket Question
Posted: Wed Oct 24, 2012 09:49 PM
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 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Continue the discussion