trying to use sockcli.prg

Post Reply
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

trying to use sockcli.prg

Post by vilian »

I am trying to use sockcli.prg. I connect in the server, but I do not obtain to send nothing! If active log I see the following one:

07/31/06 16:43:02: Connect Socket handle: 1928
07/31/06 16:43:02: Write Socket handle: 1928
07/31/06 16:43:26: IMP01|0|0001|
07/31/06 16:44:32: IMP01|0|0001|


#include "FiveWin.ch"

static oWnd, oSocket

function Main()

local oBar

DEFINE WINDOW oWnd TITLE "Client socket"

DEFINE BUTTONBAR oBar OF oWnd _3D

DEFINE BUTTON OF oBar ACTION Client() TOOLTIP "Connect"

DEFINE BUTTON OF oBar ;
ACTION oSocket:SendData( "IMP01|0|1001|" ) ;
TOOLTIP "Send data"

DEFINE BUTTON OF oBar ;
ACTION SendFile() TOOLTIP "Send file"

ACTIVATE WINDOW oWnd

return nil

FUNCTION Client()
LOCAL n

oSocket = TSocket():New( 1853 )
oSocket:lDebug := .T.
oSocket:cLogFile := "LOG.TXT"

oSocket:bRead = { | oSocket | MsgInfo( oSocket:GetData() ) }

// Never use a MsgInfo() here because it hangs Windows!!!
oSocket:bConnect = { || oWnd:SetText( "Connected!" ) }

oSocket:bClose = { || MsgInfo( "Server has closed!" ) }

oSocket:Connect( "10.10.1.1" ) // use the server IP address here


RETURN nil

FUNCTION SendFile()
LOCAL uBuff

uBuff := oSocket:GetData()

RETURN nil
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Vilian,

If you are testing both samples\sockserv.prg and samples\sockcli.prg at the same computer, then you have to change this line in sockcli.prg:

oSocket:Connect( "127.0.0.1" ) // use the server IP address here

Here they are working fine with FWH 2.7 July 2006.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post by vilian »

Thanks Antonio,
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post by vilian »

Antonio,

How I make in sockserv.prg to return information to sockcli.prg?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Post Reply