A TCP connection is no more than a pair of byte streams - one in each
direction. You have to define your own structure for each byte stream and the
procedures for use i.e. a protocol. lt will be easier if you can use a standard
protocol such as http. An http POST is one way to send an array of bytes to a
server and to receive a response.
if you want to define your own protocol then you could send your array of bytes
as an integer length followed by the bytes encoded one after the other. If you
want your protocol to be platform independent then be careful to define the bit
order (little endien or big endien) and how multibyte integers are encoded (low
order byte first or high order byte first).Your protocol could be as simple as
one side iniiates a connection, sends a byte count followed by the byte array.
The receiver, once it has received all bytes (as given by the byte count)
processes the data and then returns the response preceded by a byte count. Of
course your application may be more complex than that, which is why protocol
design is such an interesting problem.
-------- Original message --------From: James Richters via fpc-pascal
<fpc-pascal@lists.freepascal.org> Date: 11/09/2020 21:59 (GMT+00:00) To:
'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org> Cc: James
Richters <ja...@productionautomation.net> Subject: [fpc-pascal] Sending Hex
codes over TCP/IP I'm trying to figure out how to send and receive Arrays of
Bytes or perhaps a buffer of hex codes over TCP/IP, but everything I find
seems to want to send and receive strings. Can someone please point me in the
right direction on how to do this? Basically I want to make a connection
to an IP address at a specific port and then send some bytes to the server then
get some bytes back from the server. The data sent is just hexadecimal and it
can't be followed by linefeeds or carriage returns, and I want to just receive
the bytes back into a buffer of some sort so I can look at it one byte at a
time. I prefer some kind of array of bytes so I can just access the bytes with
elements of the array. I've been going round and round trying to figure this
out. Any help is greatly
appreciatedJames_______________________________________________fpc-pascal
maillist -
fpc-pascal@lists.freepascal.orghttps://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal