GithubHelp home page GithubHelp logo

t3ss3ract / java-socket-programming Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bhandariroshan/java-socket-programming

0.0 1.0 0.0 55 KB

Socket Programming in Java

Java 92.84% Python 7.16%

java-socket-programming's Introduction

Java Socket Programming Example

Simple client-server socket programming in Java. This program will be used to transfer files from client to server. Server will be listening on a port (say port# 5050) and Client will connect to Server and transfer files to Server.

Client accepts command line parameter to set the number of concurrent file transfers. For example, java Client 5 will transfer five files concurrently at any given time as long as there are enough files.
If concurrency number is not entered, it should transfer one file at a time (aka concurrency=1), by default.

Files

  1. Client.java: Client Application to make socket connection with the Server.
  2. Server.java: Server Application to accept socket connection from client. This can accept multiple connection.
  3. FileTransfer.java: Scans all the files inside client directory and transfers it to server based on the concurrency factor sent by Client.java
  4. FileDownload.java: when a connection is made at a port by the client for file transfer, Server accepts the connection request and sends it to FileDownload which ultimately downlods file in the connection and saves it in the server directory.

Test Cases

  1. Create a dataset with 100 files each 10MB size and transfer with concurrency 1, 2,4 and 8 and measure throughput
  2. Create a dataset with 10 files each 1GB size and transfer with concurrency 1, 2, 4 and 8 and measure throughput
  3. Combine above two datasets in a single dataset and transfer with concurrency 1,2,4 and 8 and measure throughput

Generating Test Data

  1. Install python

  2. From terminal run python producefile.py

    -- To produce 10MB file, type 10

    -- To produce 1GB file, type 1000

Note: data will be produced inside client directory

After tests are done, draw figure for each tests case in item#2 where x-axis is concurrency value and y-axis is throughput.

Compiling the program

  1. Use the command javac -cp . -Xlint:deprecation Client.java from terminal. It will generate Client.class file
  2. Use the command javac -cp . -Xlint:deprecation Server.java from terminal. It will generate Server.class file

Running the program

  1. Go to terminal, type java Server. This will run Server, which will accept connections from the client.
  2. Open another terminal, type java Client, enter concurrency when promted, this will run client and start transfering files to the server from the client directory.

java-socket-programming's People

Contributors

bhr724 avatar

Watchers

James Cloos avatar

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.