> My record type is like;
> TData = record
>   age: integer;
> end;
> PData = ^TData;
>
> I send data as follows succesfully;
> Send(Data, SizeOf(TData));
>
> and receive;
> Receive(Data, SizeOf(TData));
>
> What i want to do is to send a couple of record types (seperately); and
> distinguish them on the client side.
> i tried moving data into a PChar variable, ant put some distinguisher in
> front of data, but this didnt worked out, or i couldnt..

I will assume you are using TCP, not UDP.
I see two problems in your design:
1) Receive will receive what is available, at most the size you specifyed.
It is well possible that not all data are already arrived. It works in you
case because you sent an integer (4 bytes) which is likely to arrive in one
data packet. If you had larger data, it is likely it would be split into
several packets and you would get several OnDataAvailable events.
2) TCP is a stream oriented connection. This means there is no record
concept in the data stream. It is just a bidirectional byte stream, just
like a simple file stream. The impact is that the receiver has no way to
know you send 2 of your records seperately or a single large record. You
must add yourself a delimiter between your records, or add a length field in
front of your record.

Please have a look at "TCP/UDP primer" available from
http://wiki.overbyte.be/wiki/index.php/FAQ.Difference

--
[email protected]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to