Skip to content

A program that downloads a file from the Internet given a URL over TCP.

Notifications You must be signed in to change notification settings

prempreetbrar/TCPFileDownloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TCP File Downloader

A program that downloads a file from the Internet given a URL over TCP. Watch a gif of me interacting with it below!

photo  

Features

  • Supports both HTTP and HTTPS URLs; if the protocol is HTTP, a regular Socket is used to establish a TCP connection; if the protocol is HTTPS, a secure connection is established with the server using an SSLSocket.
  • Operates in non-persistent HTTP mode; once the object is downloaded, the client closes the underlying TCP connection.
  • URLs must be properly formatted with the following syntax: protocol://hostname[:port]/pathname, where protocol is either HTTP or HTTPS, hostname is the name of the web server, [:port] is an optional part which specifies the server port (default is 80 for HTTP and 443 for HTTPS), pathname is the path of the requested object on the specified host.
  • Reads the server response line by line to first identify the end of the header fields (by looking for \r\n), and then reads the remainder of the server's response (the file itself) chunk-by-chunk using a buffer for improved performance.

If you want to start up the project on your local machine:

  1. Download the code as a ZIP:

    download  

  2. Unzip the code:

    file  

  3. Open the folder in an IDE, such as VSCode:

    code  

  4. Obtain the URL of a file from the internet, copy it. Then, run the code by doing

       java ClientDriver -u <url_copied_from_internet>
    



photo  

  1. Interact with the file as you please!

    enjoy