BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: How to improove it tcp file transfer.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Nov 23, 2003 11:24 pm    Post subject: Re: How to improove it tcp file transfer. Reply with quote



"Santy Concepción" <NO*SPAM*SANTYCG (AT) terra (DOT) es> wrote


Quote:
Image.Picture.LoadFromFile('desktop.jpg');

Why don't you use LoadFromStream() instead? Then you don't need to use a
file at all, and thus it will be faster because file I/O is slow in general.
for example:

var
FStream: TMemoryStream;
JPEG: TJPEGImage;
begin
FStream := TMemoryStream;
try
JPEG := TJPEGImage.Create;
try
AThread.Connection.ReadStream(FStream, -1, False);
FStream.Position := 0;
JPEG.LoadFromStream(FStream);
Image.Picture.Assign(JPEG);
finally
JPEG.Free;
end;
finally
FStream.Free;
end;

FYI, you are updating a VCL GUI component (TImage) from the server's
OnExecute event. You should not be doing that. The OnExecute event is
triggered in the context of a worker thread, not the main VCL thread. You
should be using the thread's Synchronize() method in order to access GUI
components in a safe manner, because the VCL is not thread-safe to begin
with.

Quote:
fStream := TFileStream.Create('prueba.jpg',fmOpenRead
or fmShareDenyNone);

Shouldn't that be opening "image.jpg" instead?

Also, here too, if you change the client code to to use a TStream instead of
a file, you can speed up the transfers since file I/O is slow in general.


Gambit



Back to top
Simon Devlin
Guest





PostPosted: Mon Nov 24, 2003 10:21 pm    Post subject: Re: How to improove it tcp file transfer. Reply with quote



In general, remote control apps don't send the whole screen, just the
changes between updates (such as mouse x,y changes) etc. In addition, these
updates would usually be compressed (CPU time cheap compared to bandwidth
costs) and hopefully encrypted). I'm not sure how you'd do this, but
presumably some kind of logical operation (xor etc) would do the trick.

You could always take a look at the VNC source code - it's not Pascal, but
the principals ought to be the same.

HTH

"Santy Concepción" <NO*SPAM*SANTYCG (AT) terra (DOT) es> wrote

Quote:
Hi!

I'm trying to remote-control another computer from my computer. All work
fine, I can "see" the other computer screen and I can control the mouse.
The cliente (remote computer) sends a desktop screenshot (JPG file)
Server.
The problem is that it is slow, even with computers on the same LAN.
The JPG file is in gray-scale format and 8bit quality, so the file is
about
75 Kb!


<snip>

Quote:
Is this the most efficient way to transfer images? Is it possible to speed
it up?




Back to top
Michael Baytalsky
Guest





PostPosted: Mon Nov 24, 2003 10:45 pm    Post subject: Re: How to improove it tcp file transfer. Reply with quote



Hi Santy,

Try this Remote Assistant utility - it's really cheap and you
can use it for free for a while.
Check it out at: http://www.retaildecision.com/products/remassist

It has: screen, file transfer, clipboard transfer and chat.

In my opinion it doesn't make sence to design something
on your own. Also, Remote Assistant is based on the source code
by Danijel Tkalcec ([url]www.deltasoft.hr/remote)[/url].


Sincerely,
Michael


"Santy Concepción" <NO*SPAM*SANTYCG (AT) terra (DOT) es> wrote

Quote:
Hi!

I'm trying to remote-control another computer from my computer. All work
fine, I can "see" the other computer screen and I can control the mouse.
The cliente (remote computer) sends a desktop screenshot (JPG file)
Server.
The problem is that it is slow, even with computers on the same LAN.
The JPG file is in gray-scale format and 8bit quality, so the file is
about
75 Kb!

In the server app, this is the code for reading the image file (Server
onExecute):

FStream := TFileStream.Create('desktop.jpg', fmCreate);
with AThread.Connection do
try
ReadStream(FStream, -1, False);
finally
FStream.Free;
end;
Image.Picture.LoadFromFile('desktop.jpg');

And this is the client-side code for sending the file:

CreateDesktop('image.jpg');
if fileexists('image.jpg') then
begin
fStream := TFileStream.Create('prueba.jpg',fmOpenRead or
fmShareDenyNone);
with IdTCPClient2 do
if connected then
begin
try
OpenWriteBuffer;
try
WriteStream(FStream, True, True, 0);
CloseWriteBuffer;
except
CancelWriteBuffer;
end;
finally
FStream.Free;
end;
end;

Is this the most efficient way to transfer images? Is it possible to speed
it up?
Should I use a different TTimer component (one for text messages and
another
for sending files)?
How about the buffer size, is it possible to adjust it to make the
transfer
faster?

Thanks to all!





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.