Board index » delphi » sending dynamic arrays of record's thru socket

sending dynamic arrays of record's thru socket

Hallo
How can I send dynamic arrays of record's thru socket in delphi 6
Can anyone help me???
Greets,
Batek Swiatek
 

Re:sending dynamic arrays of record's thru socket


parse through the array and send each array item

here is some pseudo-code
var
  I: Integer;
  A: array of TMyRecord;

for I := Low(A) to High(A) do
  Socket.Send(A[I]);

Quote
"Bart3omiej |witek" <bswia...@radom.net> wrote in message

news:a8t95k$fat$1@panorama.wcss.wroc.pl...
Quote
> Hallo
> How can I send dynamic arrays of record's thru socket in delphi 6
> Can anyone help me???
> Greets,
> Batek Swiatek

Re:sending dynamic arrays of record's thru socket


that was my idea but that does not work
how can I synchronize writeing and reading .....
Bartek Swiatek
U?ytkownik "Gasper Kozak" <gasper.ko...@tobonet.com> napisa3 w wiadomo?ci
news:FtCs8.30$WO2.1220@news.siol.net...
Quote
> parse through the array and send each array item

> here is some pseudo-code
> var
>   I: Integer;
>   A: array of TMyRecord;

> for I := Low(A) to High(A) do
>   Socket.Send(A[I]);

> "Bart3omiej |witek" <bswia...@radom.net> wrote in message
> news:a8t95k$fat$1@panorama.wcss.wroc.pl...
> > Hallo
> > How can I send dynamic arrays of record's thru socket in delphi 6
> > Can anyone help me???
> > Greets,
> > Batek Swiatek

Re:sending dynamic arrays of record's thru socket


what do you mean by "it doesn't work"? If you have an array of records,
sending each record should be trivial.
While you're sending data through a socket, you cannot read from it. Isn't
there an event that tells you when new data has arrived to the socket?

Quote
"Bart3omiej |witek" <bswia...@radom.net> wrote in message

news:a8v81j$4i2$1@panorama.wcss.wroc.pl...
Quote
> that was my idea but that does not work
> how can I synchronize writeing and reading .....
> Bartek Swiatek
> U?ytkownik "Gasper Kozak" <gasper.ko...@tobonet.com> napisa3 w wiadomo?ci
> news:FtCs8.30$WO2.1220@news.siol.net...
> > parse through the array and send each array item

> > here is some pseudo-code
> > var
> >   I: Integer;
> >   A: array of TMyRecord;

> > for I := Low(A) to High(A) do
> >   Socket.Send(A[I]);

> > "Bart3omiej |witek" <bswia...@radom.net> wrote in message
> > news:a8t95k$fat$1@panorama.wcss.wroc.pl...
> > > Hallo
> > > How can I send dynamic arrays of record's thru socket in delphi 6
> > > Can anyone help me???
> > > Greets,
> > > Batek Swiatek

Re:sending dynamic arrays of record's thru socket


Quote
Bart3omiej |witek wrote in message ...

<on transmitting dynamic arrays>

<"just send them!">

Quote
>that was my idea but that does not work
>how can I synchronize writeing and reading .....

In a single program, you're either reading or writing.
Synchronising _is_ done by sending it through a socket
on the sending side and reading it on the receiving side.

So far, you've just said that "it doesn't work". That's
not very helpful. (Try to get a job at a helpdesk some
time, just three months for experience. You'll learn to
_love_ those people who can be no more specific than "it
doesn't work".)

I can imagine two problems. Sending a single record may
be a problem, because a TCP connection transports a byte
stream, not records; or sending an unknown number of
records may fail, probably because the receiving side
doesn't know when to stop.

The first problem may be solved by buffering received
data until the buffer contains at least a record's worth.
You can then copy that to where it must go and drop it
from the buffer.

The second problem can be solved by sending not just the
bare data, but encoding it or marking it up a bit. Design
a simple one-way protocol. For example, first send the
number of records, then (or first) send the size of every
record, then send the individual records. You can extend
this as far as you like: you can put a complete description
of the record in the header, escape non-printing characters
in the records, separate them with markers, mark everything
up as SGML, whatever. The sky is the limit (and the sky is
a very big place).

Note that these are only the two problems I think you might
be having. Don't let that stop you from having other ones,
and asking about them. Just, please, tell us what they _are_
when asking about them.

Groetjes,
Maarten Wiltink

Other Threads