# The Phex Download Specification

#### for Phex 0.X

## Classes

### SwarmingManager

The SwarmingManager manages the list of all downloads. Also it manages and triggers SWDownloadWorkers. The functionalites offered are:

- Add and remove files to the download list.
- Managing of download file priority.
- Regulary saving the download list to a file.
- SWDownloadWorker management.
- Allocating a DownloadSet for a SWDownloadWorker.

### SWDownloadWorker

The download worker is running in a separated thread. It is allocated by the SwarmingManager.
The download worker asks the SwarmingManager to allocate a DownloadSet. A DownloadSet is a working unit with a reference to a download file that has a open segments to download and a download candidate no other SWDownloadWorker has allocated yet. After allocating the DownloadSet the SWDownloadCandidate associated with the DownloadSet can not be allocated in a DownloadSet anymore.

The SWDownloadWorker is now starting the initialisation process to download from the allocated SWDownloadCandidate in the DownloadSet.
First the SWDownloadWorker tries to connect to the SWDownloadCandidate. Depending on the information of the candidate and the configuration of the local host (firewall) a PUSH request or direkt connection to the host is tried. If direct connection fails a PUSH request might be initialized also.
If the connection failes a error code is assigned to the download candidate, the download set is deallocated and the download worker tries to preceed with the next download segment.

If the connection is successful the process of exchanging the HTTP handshake begins. A free SWDownloadSegment gets allocated from the download file and is passed to the DownloadEngine to exchange the HTTP handshake.

Java is a trademark of Sun Microsystems, Inc.

Copyright © 2001, 2006 The Phex Team, GPL-2 or later.