FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Sockets write & read question
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Sockets write & read question
Posted: Mon Jun 16, 2014 07:42 AM

Hello,

I'm busy writing a program that will communicate with an other program (.NET)
I have to send some data to that program, and they send some data back.

I was thinking that I have to write aprogram that first act as client and then as server.
So I first send some data (client socket), and then wait till the other program send some data back (server socket).

Is that correct, or can I send some data, and receive the answer in the same function with the return parameter?

My program always send some data first, and than the .NET program wil answer with some data.

Thanks

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Sockets write & read question
Posted: Mon Jun 16, 2014 08:16 AM

Marc,

You can find in FWH\samples sockserv.prg and sockcli.prg that can help you to see how they work.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Sockets write & read question
Posted: Mon Jun 16, 2014 08:25 AM

Antonio,

That's what I did now. First I used the code in sockcli.prg and than sockserv.prg.
So first call oSocket:SendData
and then
oSocket:bAccept = { | oSocket | oClient := TSocket():Accept( oSocket:nSocket ),;
oClient:Cargo := ST_COMMAND,;
oClient:bRead := { | oSocket | OnRead( oSocket ) },;
oClient:bClose := { | oSocket | OnClose( oSocket ) } }

oSocket:Listen()

But I was maybe thinking that oSocket:SendData could return an answer, but it's working now with the previous code.
Thanks

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Sockets write & read question
Posted: Mon Jun 16, 2014 08:55 AM

Marc,

Usually you don't get an inmediate answer (that would block the communications), instead of that, we are called when there is data for us

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion