Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Project: Socket Programming - UDP

Objectives:

- Learn socket programming in Java: UDP

-  Cement your understanding of reliable transfer protocols

Develop a reliable transfer protocol over UDP. Focus on a Stop- and-Wait protocol.

Overview

This framework provides:

-  a template for the reliable transfer protocol implementation.

-  a testing framework, with a graphical user interface.

How to use the testing framework later in the project description.

The main goal of this project is to implement a Stop-and-wait reliable transfer protocol based on the provided template.

-  MyDataPacket,
-  MyAckPacket,
-  MyServerSocket and  
-  MySocket

The former two classes are used to handle data and ack packets, respectively. They are fully implemented. Implement the latter two classes, i.e., MyServerSocket and MySocket. These classes have the following interface:

class MySocket
{
    public MySocket(InetAddress IPAddress, int portNumber)
 
    public OutputStream getOutputStream()
}
 
class MyServerSocket
{
    public MyServerSocket(int port)
 
    public InputStream getInputStream()
}

These classes are quite similar to the TCP sockets available in Java: Socket and ServerSocket. Therefore, we make a few simplifications:

-  No connection-level multiplexing. We assume that only one client at a time connects to a MyServerSocket open at a given port. Therefore, MyServerSocket has no accept method.

Furthermore, we are not going to implement any mechanisms for opening or closing of connections.

-  Unidirectional transfer. Our sockets implement transfer of data in one direction only. To send data, MySocket must be used. To receive data, MyServerSocket is used.

Consequently, there is no getInputStream in MySocket and no getOutputSteam in MyServerSocket

A benefit of the above interface is that we can use it with all the familiar stream classes available in Java, such as DataOutputStream or BufferedReader. An example program that would use our sockets can look as follows:

// Sender (Client)
    ...
    MySocket socket = new

MySocket(InetAddress.getHostByName("somhostname.edu"), 12345);

    DataOutputStream out = new DataOutputStream(socket.getOutputStream());

    out.writeBytes("Hello world!");
    ... 

// Receiver (Server)
    ...

    MyServerSocket serverSocket = new MyServerSocket(12345);

    BufferedReader in = new BufferedReader(new

InputStreamReader(serverSocket.getInputStream()));

    String sentence = in.readLine();

    System.out.println("Received: " + sentence);
    ...

Java, Programming

  • Category:- Java
  • Reference No.:- M9131000
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Java

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As