Giter VIP home page Giter VIP logo

file-transfer-demo's Introduction

CS 372 Intro to Computer Networking | Project 2 - File Transfer

Design and implement a simple file transfer system, i.e., create a file transfer server and a file transfer client.

Compile / Run Instructions

The server is in C and the client is in Python 2.7

Server

To compile the server, run:

gcc -Wall -o ftserver ftserver.c

In the root directory. Then execute the server as follows: ./ftserver <portNumber>.

Note: I was unable to implement immediate SIGTERM handling. So when you Ctrl-C to exit the server, the server will shut down gracefully AFTER the next client request. This is a very annoying problem but it is due to the accept() call blocking everything, including the SIGTERM handler.

Client

To run the client, you have to pass the keyword arguments as follows:

python ftclient.py --server_host=<server_host> --server_port=<server_port> --command=<command> --file=<file> --data_port=<data_port>

Arguments List:

  • --server_host or -sh
    • specify host you want to connect to
    • required
  • --server_portor -sp
    • specify the server port you want to connect to
    • required
  • --command or -c
    • specify the command you want to execute on the server: either (-l or -g)`
    • required
  • --filename or -f
    • specify the file you want to get (if issuing a get command)`
    • required with -g
  • --data_port or -dp
    • specify the data port you want to transfer using
    • required

Note: The --file argument only goes with -g command.

List Directory Example:

python ftclient.py --server_host=flip1.engr.oregonstate.edu --server_port=50010 --command=-l --data_port=50011

Get File Example:

python ftclient.py --server_host=flip1.engr.oregonstate.edu --server_port=50011 --command=-g --file=binny.bin --data_port=50011


Extra Credit

  • Known Extra Credit: The Get File command -g works with non-text files. For example, transfer the included binary binny.bin or the included image file kitt.png. Even the ftserver.c works.
  • Possible Extras:
    • Arguments support short and long forms (e.g. -c or --c) and have very strict validation
    • Error handling and interaction messages are graphically-displayed and detailed
    • Both programs clean up after themselves (close the sockets) and can re-use the same ports over and over

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.