TSocket Question

TSocket Question

Postby PeterHarmes » 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: Select all  Expand view


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

Postby PeterHarmes » Wed Oct 24, 2012 8:21 am

Hi,

Anyone have any ideas?

Best regards,

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

Re: TSocket Question

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TSocket Question

Postby FiveWiDi » Wed Oct 24, 2012 9: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 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1189
Joined: Mon Oct 10, 2005 2:38 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 97 guests

cron