Sockets write & read question

Post Reply
Marc Vanzegbroeck
Posts: 1163
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Sockets write & read question

Post by Marc Vanzegbroeck »

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
User avatar
Antonio Linares
Site Admin
Posts: 42660
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 69 times
Been thanked: 96 times
Contact:

Re: Sockets write & read question

Post by Antonio Linares »

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
Marc Vanzegbroeck
Posts: 1163
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Sockets write & read question

Post by Marc Vanzegbroeck »

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
User avatar
Antonio Linares
Site Admin
Posts: 42660
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 69 times
Been thanked: 96 times
Contact:

Re: Sockets write & read question

Post by Antonio Linares »

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
Post Reply