Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:19:20+00:00 2026-05-31T15:19:20+00:00

I am supposed to create my own ‘reliable transport protocol’ using UDP and written

  • 0

I am supposed to create my own ‘reliable transport protocol’ using UDP and written in java. Not too terribly difficult, however, to make it a more organized implementation, I was hoping on creating my own version of the DatagramPacket class by extension, adding some byte headers to be read upon receipt from remote host, and pass this new type of packet through a regular DatagramSocket via typecast, or perhaps extend the DatagramSocket class as well to implement more methods. Turns out the DatagramPacket class is final, and I’m too stubborn to give up on my idea. Anyone know any ways around this to achieve the ability to send such a custom packet type? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:19:22+00:00Added an answer on May 31, 2026 at 3:19 pm

    Subclassing to provide alternate behavior is one way, but it’s not always feasible as you’ve noticed. Can you somehow come up with a solution based on composition rather than inheritance?

    See if you can make it work by having your class have-a DatagramPacket as a member variable, enhancing its behavior by wrapping your class’s methods around the DatagramPacket‘s.

    It sounds like you want to still send DatagramPackets in the end, but with some special processing in addition to what DatagramSocket already does. Here’s a design that comes to mind (I’m sure there are many others):

    class JayPacket {
    
        private byte[] payload; // Payload without any flow control bytes
    
        // Other flow control magic
    
        public DatagramPacket asDatagramPacket() {
            // Package this instance's payload plus your flow control bytes 
            // into a DatagramPacket
        }
    
        public static JayPacket fromDatagramPacket(DatagramPacket datagramPacket) {
            // Parse the control bytes out of the given DatagramPacket 
            // and construct a JayPacket
        }
    }
    

    Then another class would wrap around DatagramSocket to manage JayPacket <--> DatagramPacket conversions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm supposed to use watershed to allow users to create and post their own
Sage is supposed to be able to create compiled code using Cython. I have
I'm trying to create my own Media Player application using a WPF MediaElement. I
Suppose I have a stored procedure that manages its own transaction CREATE PROCEDURE theProc
I'm supposed to create a simple rule engine in C#. Any leads on how
I'm working on an application that is supposed to create products (like shipping insurance
I am working on an assignment for networking where we are supposed to create
everytime my page loads, im supposed to create a datatable (also a jquery plugin)
I want to create a very basic 3D modeling tool. The application is supposed
I'm trying to create an installer-like application. Here is what its supposed to do:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.