With the Indy component TIDTCPServer
in Delphi you receive a striped packet that the client sent of 64 KB.
How do I receive the complete packet in the Execute event of the Server?
Thank you
With the Indy component TIDTCPServer
in Delphi you receive a striped packet that the client sent of 64 KB.
How do I receive the complete packet in the Execute event of the Server?
Thank you
You have no control over this, TCP is not a message oriented protocol , but a data stream oriented protocol .
In other words, the TCP stack, at any point (it can be the client's own network card, routers, switch, hubs, etc.) can divide a message into the number of packets it deems convenient (and regularly does, for example ). example as the packets go through old networks with different capacities, speeds or even that work on protocols other than TCP).
Another way of looking at it is that if you send the following messages
On the client, you could receive all combinations of sequences, to name a few examples:
In fact, speaking of your particular question, no network that I know of would be capable of transmitting 64 Kb in a single packet, the fact that you see only two packets is a mere coincidence and a product of the particular network and equipment where you are running. your client or server, but on another network, another computer, even the same computer under different conditions, you would most likely see different behavior.
It is normal to design (higher level) message-oriented protocols on top of TCP, but in this case, to implement solutions you must keep in mind how the underlying protocol works.
It sounds more complicated than it is, there are basically three ways to work.
There are plenty of examples of all of these types on the Internet today.
Assuming the case of fixed-length messages , and taking your 64Kb example, the simplest way to implement it (for illustrative purposes only), is to make the ReadTimeout very large , and for the component itself
TidTCPServer
to wait until it reads 64Kb. , for instance:You can easily test the theory, by making a single 1Mb upload, from a client, like this:
This causes the message counter on the server to go up to 16. Now with the example code, you can play and send, for example, 8Kb packets, wait a few seconds and send another packet, and you will see how the server read on in 64Kb chunks.