Jump to content
John van de Waeter

TCP. Reduce sending and receiving to avoid mobile network latency.

Recommended Posts

Hi All,
I have an Indy tcp client and Indy tcp server, all working great.


Yet I would like to reduce the connection time

The "protocol" is as follows:
Clients Connects
Client sends size of idBytes (write Int32)
Clients sends encrypted data (idBytes) containing command or question.
Server receives and prepares answer
Server encrypts answer
Server sends size of answer (IdBytes, write int32)
Server sends data (idBytes)
 

Every sending of a packet induces radio-transmissions which have a long latency compared to a wired connection.

 

When I download a picture I use  
on serverside:
...
 AContext.Connection.IOHandler.Write(astream,astream.Size,false);
...
and on clientside:
...
 TCPClient.IOHandler.ReadStream(astream, -1, True)
...

This sending and receiving of a stream has the possibility of specifying the size of the stream in the first bytes.

My question: is it possible to send a TIdBytes with the size included? So the receiving end knows how many bytes to read, just like when using a stream?

 

It would save one extra radio latency.

Thanks in advance,
John

 

 

 

Share this post


Link to post

The most obvious answer is to prepare the packets manually and send them via single call. There are also plenty of buffered stream implementations which will take the burden of low-level memory management. But probably components have additional features like built-in buffering.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×