SunQuest
           FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old April 5th, 2004, 12:59 AM
ajbufort ajbufort is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 ajbufort User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Speeding Up FTP / Threads

Hello All,

I am writing an app in Delphi that takes continuous captures of the client's screen and FTPs them to a server. I have one thread taking the captures and another FTPing them as they are taken. The speed of the captures far surpasses the speed ot the uploads (as one might expect). The ratio is currently something like 3 jpeg uploads for every 50 screen captures. I need to improve my upload rates so that another app can pick up the 'stream' and display them one after another in a reasonable time frame (this app is Flash MX, by the way).

These two functions, while not all-inclusive in terms of my code, represent my current approach:

Code:
function ProcessScreenCaptures(Ptr : Pointer) : LongInt; stdcall;
var
  jpeg: TJpegImage;
  fileName: string;
  x: Integer;
begin
  x := 0;

  while (KeepProcessing) do
  begin
    x := x + 1;
    fileName := 'screen_' + IntToStr(x) + '.jpg';
    jpeg := WindowsScreenCapture;
    jpeg.SaveToFile( fileName );
    jpeg.Free;
  end;
end;

function UploadCaptures(Ptr : Pointer) : LongInt; stdcall;
var
  fileName: string;
  x: Integer;
begin

  x := 0;

  while (KeepProcessing) do
  begin
    MakeFTPConnection();
    x := x + 1;
    fileName := 'screen_' + IntToStr(x) + '.jpg';
    UploadFile( fileName );
    CloseFTPConnection();
  end;
end;


I am a newbie to Windows-API programming, and especially threads, so I am struggling to make this work efficiently.

Yet another problem I am having is that mouse movement on the client becomes 'choppy' once the capture app is started. In an attempt to allieviate these problems, I started peppering my code with 'Application.ProcessMessages' lines. This seems very inelegant to me - I know there has to be a better solution out there. It gave me some performance gains, but not nearly what I need. I need the same skill that the pros have, where they can have an app working away in the background at some heavy task, with the user oblivious to the action all the while. That's what I am shooting for here. I thought threads would give me that, but so far they haven't. I know FTP is a notoriously slow protocol, but there's gotta be something out there that can speed up my app in that regard as well.

Can anyone help me on this? Any advice/schooling would be much appreciated!

Thanks,

-Tony

Reply With Quote
  #2  
Old April 10th, 2004, 12:59 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,430 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 21 h 41 m 55 sec
Reputation Power: 784
One thing you could do is keep the FTP connection open instead of opening and closing it each time. This will reduce some of the overhead.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Speeding Up FTP / Threads


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway