Board index » delphi » Sending and receive record using TServerSocket and TClientSocket

Sending and receive record using TServerSocket and TClientSocket

What is the best way to send and receive RECORD using TServerSocket and
TClientSocket?

Thank you
EB

 

Re:Sending and receive record using TServerSocket and TClientSocket


The best way (in my opinion) is to use a TWinSocketStream with your
TClientSocket and TServerSocket. Your client would need to be blocking and
your server would need to be threadblocking. Use TWinSocketStream.Write on
the client side and TWinSocketStream.read on the server side. I can send you
an example of uploading a file to a server (via TClientSocket/TServerSocket)
if you require it. This example sends a header record identifying the
filename and size as well as the actual file contents.

Paul

Quote
"Eric Bilodeau" <ebilod...@traf-park.com> wrote in message

news:3abf52ec$1_1@dnews...
Quote
> What is the best way to send and receive RECORD using TServerSocket and
> TClientSocket?

> Thank you
> EB

Re:Sending and receive record using TServerSocket and TClientSocket


If you mean a database record there are several ways, one real easy way is
to use a tstring list.
Add each field of your record to the list, then write the lists comma text
to the other end. IE myindyclient.writeln(mylist.commatext);
If you want to send a whole recordset have two lists, one to hold the each
record as commatext, then after you fill that list send its commatext to the
other side.
very easy to do.
then just reconstitute it on the other side with another stringlist.

Or you could use XML to do the same thing, the tstringlist is much easier to
implement IMHO.

Quote
"Eric Bilodeau" <ebilod...@traf-park.com> wrote in message

news:3abf52ec$1_1@dnews...
Quote
> What is the best way to send and receive RECORD using TServerSocket and
> TClientSocket?

> Thank you
> EB

Re:Sending and receive record using TServerSocket and TClientSocket


Use Read and WriteBuffer commands

On the Server:

    Readbuffer(DataBuf,sizeof(DataBuf));

On the Client :

  WriteBuffer(DataBuf,Sizeof(DataBuf),True);

DataBuf is a var for the same TRecord Structure in each program

Quote
Eric Bilodeau <ebilod...@traf-park.com> wrote in message

news:3abf52ec$1_1@dnews...
Quote
> What is the best way to send and receive RECORD using TServerSocket and
> TClientSocket?

> Thank you
> EB

Other Threads