Board index » delphi » Indy client->server localhost fast?

Indy client->server localhost fast?

What is the fastest way to send a large bitmap (4 MB) through a localhost
connecting from an Indy client to the server?

The bitmap source can either be a buffer or a stream, likewise the
destination can either be a buffer or stream.

I have found that writing a stream TcpClient.WriteStream(myStream) is very
slow, likewise reading into a buffer AThread.Connection.ReadBuffer(MyBuf^,
xManyBytes) is quite slow too.

The fastest way I have found so far is to write a buffer and read a stream.
It works well but is still somewhat slow. It takes a noticeable time (300ms)
to pass a 4MB bitmap through. Can I get any faster than this or is this
about as fast as Indy can handle? (I'm on a XP2000+ with WinXP SP1.

--
Chuck

 

Re:Indy client->server localhost fast?


Just further to that...

It is the server part (the listening part) which is taking a long time to
read the buffer into a stream. i.e. I can send the 4 MB bitmap using
WriteBuffer() quickly. Then on the server side I do:

Len:=AThread.Connection.ReadInteger; // get the length. i.e. 4 MB
AThread.Connection.ReadStream(myStream);

If I step over this code in the IDE, the ReadStream() has the half second
delay. As far as I know all the data should already be available (it has
been sent by the client) so could this call not be instantaneous?

--
Chuck

Re:Indy client->server localhost fast?


....and yet another question!

If I'm sending this 4 MB bitmap over a dial up connection, I want to know
how much has been sent after calling WriteBuffer().

For example

WriteBuffer(myBitmap^, size_of_bitmap); // this returns immediately even tho
the bitmap is still sending
...
sleep a few seconds
...
// now how do I check  how much is remaining in the write buffer i.e. is
there 3.9 MB left to write or 3.2 MB, etc?

--
Chuck

Re:Indy client->server localhost fast?


Quote
> The fastest way I have found so far is to write a buffer and read a
stream.
> It works well but is still somewhat slow. It takes a noticeable time
(300ms)
> to pass a 4MB bitmap through. Can I get any faster than this or is this
> about as fast as Indy can handle? (I'm on a XP2000+ with WinXP SP1.

4 MB in 300 ms- wow! :)

Well, with a very basic client/serversocket non-blocking setup, it takes me
1250ms to send a 3.8mg file, on a p3 450. So 450/2000*1250 = 281ms; it looks
like u pretty close to maximum transfer speed, although I could be wrong :).

-Rael

I've also been working at (parts of...) a similar app to you- perhaps we can
chat abit about it? You can reach me at my email ad.

Re:Indy client->server localhost fast?


I've done some more testing and noticed that only server-to-client sends are
slow. For example, sending 4MB from client to server takes 120ms, but
sending 4MB from server to client takes 500ms. Same data, but it's taking 4
times as long?

I can definitely feel something is not write but don't know what the problem
could be? I'm using the same code to send from Server-to-Client:

Connection.OpenWriteBuffer;
Connection.WriteInteger(Length)
Connection.WriteBuffer(Buffer^, Length);
Connection.CloseWriteBuffer;

The function returns immediately. On the client's end, I have:

Len:=Connection.ReadInteger;
// Once we have received the length, I am starting the timer using
QueryPerformanceCounter().
Connection.ReadStream(Stream, Len);
// Now stop the timer.

I'm pretty sure it's not ReadStream() which is the problem, because if I put
Sleep(1000) to allow the data to be built up then ReadStream() is quick. The
problem seems to be that ReadStream() is just waiting for the data to
arrive. Why is it arriving slow from the server?

--
Chuck

Re:Indy client->server localhost fast?


Hmmm, I get the same time both ways. Are you sure you're timing the exact
same process? I'm timing with gettickcount, maybe try that and see if you
get different results...

(perhaps u missed this?
I've also been working at (parts of...) a similar app to you- perhaps we can
chat abit about it? You can reach me at my email ad.)

Rael

Quote
Chuck <ne...@mind.com> wrote in message

news:3eb8936d@newsgroups.borland.com...
Quote
> I've done some more testing and noticed that only server-to-client sends
are
> slow. For example, sending 4MB from client to server takes 120ms, but
> sending 4MB from server to client takes 500ms. Same data, but it's taking
4
> times as long?

> I can definitely feel something is not write but don't know what the
problem
> could be? I'm using the same code to send from Server-to-Client:

> Connection.OpenWriteBuffer;
> Connection.WriteInteger(Length)
> Connection.WriteBuffer(Buffer^, Length);
> Connection.CloseWriteBuffer;

> The function returns immediately. On the client's end, I have:

> Len:=Connection.ReadInteger;
> // Once we have received the length, I am starting the timer using
> QueryPerformanceCounter().
> Connection.ReadStream(Stream, Len);
> // Now stop the timer.

> I'm pretty sure it's not ReadStream() which is the problem, because if I
put
> Sleep(1000) to allow the data to be built up then ReadStream() is quick.
The
> problem seems to be that ReadStream() is just waiting for the data to
> arrive. Why is it arriving slow from the server?

> --
> Chuck

Re:Indy client->server localhost fast?


Hi !

Little calculations - 4 MB data is 33554432 (4 * 1024 * 1024  * 8) bits of
data (with no compression).
If You are even using 100Mbit ( 100 Mega bits per second), Ethernet card
then you can sent that amount of bits in minimum time of 0,32 sec (33554432
div by (100*1024*1024).

Next - you need remeber about Ethernet frame delay time, and TCP packets
data overflow (30-40% is header rest is data), hub/switch delay, machine OS
delay ...

There you go :)

JJ

U?ytkownik "Rael" <h...@mweb.co.za> napisa3 w wiadomo?ci
news:3eb94428@newsgroups.borland.com...

Quote
> Hmmm, I get the same time both ways. Are you sure you're timing the exact
> same process? I'm timing with gettickcount, maybe try that and see if you
> get different results...

> (perhaps u missed this?
> I've also been working at (parts of...) a similar app to you- perhaps we
can
> chat abit about it? You can reach me at my email ad.)

> Rael

> Chuck <ne...@mind.com> wrote in message
> news:3eb8936d@newsgroups.borland.com...
> > I've done some more testing and noticed that only server-to-client sends
> are
> > slow. For example, sending 4MB from client to server takes 120ms, but
> > sending 4MB from server to client takes 500ms. Same data, but it's
taking
> 4
> > times as long?

> > I can definitely feel something is not write but don't know what the
> problem
> > could be? I'm using the same code to send from Server-to-Client:

> > Connection.OpenWriteBuffer;
> > Connection.WriteInteger(Length)
> > Connection.WriteBuffer(Buffer^, Length);
> > Connection.CloseWriteBuffer;

> > The function returns immediately. On the client's end, I have:

> > Len:=Connection.ReadInteger;
> > // Once we have received the length, I am starting the timer using
> > QueryPerformanceCounter().
> > Connection.ReadStream(Stream, Len);
> > // Now stop the timer.

> > I'm pretty sure it's not ReadStream() which is the problem, because if I
> put
> > Sleep(1000) to allow the data to be built up then ReadStream() is quick.
> The
> > problem seems to be that ReadStream() is just waiting for the data to
> > arrive. Why is it arriving slow from the server?

> > --
> > Chuck

Other Threads