I want to make downloading agent, guide me

i want to develop downloading agent which can download file in mulitple session.
one can resume the file to be downloaded ,after being disconnected.
for this i am using socket to connect to the Http server. but i don't know how to communicate with the http server.

Here's how to do it with Java code:
private InputStream getInputStream(String strURL, long offset)
     try
          URL url = new URL(strURL);
          URLConnection uc = url.openConnection();
          uc.setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode("username:password".getBytes()));
          if ((offset != 0) && uc.getHeaderField(0).toUpperCase().startsWith("HTTP/1.1"))
               uc.setRequestProperty("Range", "bytes=" + offset + "-");
          return uc.getInputStream();
     catch (MalformedURLException mfURLe)
          System.err.println("Malformed URL in Client Updater. Unable to receive update list: " + mfURLe.getMessage());
     catch (IOException ioe)
          System.err.println("Unable to open input stream: " + ioe.getMessage());
     return null;
}

Similar Messages

Maybe you are looking for