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

  • SEARCH
  • Home
  • 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 7534885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:08:49+00:00 2026-05-30T06:08:49+00:00

I am trying to send an image over UDP using JAVA. I have managed

  • 0

I am trying to send an image over UDP using JAVA. I have managed to implement the sender and receiver and it works for a small image (18KB in this case). When I try to send a larger image (2MB) the receiver seems to jam after sending a few hundred datagrams.

Here is the loop in my receiver which recieves each packet from the sender.

while(true) {
            packetCount++;
            System.out.println("PKT: " + packetCount);
            receievePacket = new DatagramPacket(recieveData, recieveData.length);

            try {
                receieveSocket.receive(receievePacket);
            } catch (IOException e) {
                System.out.println("Error receieving packet");
                e.printStackTrace();
            }

            bos.write(recieveData, 0, (int) DATAGRAM_MAX_SIZE);
            // Terminate loop if last packet received
            if (packetCount == packetNum) {
                break;
            }

        }

The code before this loop just receives the port number from the user, sets up the socket and recieves a single packet from the sender which specifies how many packets will be sent. This is stored in packetNum.

Can anyone think of a reason why it stalls when trying to send larger images?
Thanks

  • 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-30T06:08:50+00:00Added an answer on May 30, 2026 at 6:08 am

    You mean “receiver seems to jam after receiving a few hundred datagrams,” not sending, right? If that’s the case, then you may possibly be the victim of the infamous UDP packet loss! 🙂 There are two options:

    1. Slow down the transmission rate.
    2. Implement reliable UDP.

    The first one is easier to do and it should allow you to quickly determine if you’re experiencing packet loss. Run a few tests and see if you’re receiving the same number of bytes by varying the transmission rates (i.e. put a small sleep between sending out each packet). If you detect a difference in packet loss, then implement reliable UDP and request the re-transmission of out-of-sequence or missing packets.

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

Sidebar

Related Questions

I am trying to implement a udp image transfer program in java. The sender
I'm trying to send an image using a Java server to my Android device
I am trying to send an image from a Java desktop application to a
Hey, I'm currently trying to send an image file to a web server using
Im trying to send images over HTTP using HttpListener but some images come from
I have been struggling for a while now to send an image file over
I'm trying to send an image to a server, using HTTP Post Multipart. Everything
I am trying to send a small image along with some XML information to
I am trying to send my dynamically created silverlight 2 page/image to a an
im trying to send rest api Users.getLoggedInUser i have all the secret session and

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.