Sockets write & read question

Sockets write & read question

Postby Marc Vanzegbroeck » Mon Jun 16, 2014 7: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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Sockets write & read question

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

Re: Sockets write & read question

Postby Marc Vanzegbroeck » Mon Jun 16, 2014 8: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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Sockets write & read question

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests