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 7512893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:00:38+00:00 2026-05-30T00:00:38+00:00

Currently I’m experimenting with this code (I know it doesn’t fit the purpose). I

  • 0

Currently I’m experimenting with this code (I know it doesn’t fit the purpose).
I tried sending from 3 sources simultaneously (UDP Test Tool) and it seems ok, but I wan’t to know how this would behave if form those 10K possible clients 2K are sending at the same time? The packets are approximately 70 bytes in size. I’m supposed do to some simple operations on the contents and write the results to a database.

public class Test{

public static void main(String [] args){

    int PACKETSIZE=1400;
    int port=5555;
    byte[] bytes = new byte[PACKETSIZE];
    //ByteBuffer bb = ByteBuffer.allocate(4);
    //Byte lat=null;

    try
    {
    DatagramSocket socket = new DatagramSocket(port);
    System.out.println("The server is runing on port " + port +"\n");

        while (true)
        {
            DatagramPacket packet = new DatagramPacket(bytes, bytes.length);

            socket.receive(packet);

            System.out.println("Packet length = " + packet.getLength());                                                
            System.out.println("Sender IP = " + packet.getAddress() + "  Port = " + packet.getPort());
            for(int i=0; i<=packet.getLength();i++){System.out.print(" "+ packet.getData()[i] + " ");} 
  • 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-30T00:00:39+00:00Added an answer on May 30, 2026 at 12:00 am

    Firstly UDP sockets are not connection oriented so the number of “connections” is meaningless. The number that you actually care about is number of datagrams per second. The other issue that is normally overlooked is whether the datagrams span IP packets or not since that affects packet assembly time and, ultimately, how expensive they are to receive. Your packet size is 1,400 which will fit comfortably in an Ethernet frame.

    Now, what you need to do is limit your processing time using multiple threads, queueing, or some other processing scheme. You want the receiving thread busy pulling datagrams off of the wire and putting them somewhere else for workers to process. This is a common processing idiom that has been in use for years. It should scale to meet your needs provided that you can separate the processing of the data from the network IO.

    You can also use asynchronous or event-driven IO so that you do not have a thread responsible for reading datagrams from the socket directly. See this question for a discussion of Java NIO.

    I’m not sure if this is homework or not, but you should read The C10K problem Dan Kegel’s excellent article on this very subject. I think that you will probably find it enlightening to say the least.

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

Sidebar

Related Questions

Currently I'm doing some unit tests which are executed from bash. Unit tests are
Currently I know of only two ways to cache data (I use PHP but
Currently I am debugging the signing of an Android app. And this would be
Currently my website (production server) already have a lot of code in it. And
I am currently running into a problem where an element is coming back from
Currently, I am copying a database from my assets folder to the to the
Currently I insert a new relationship by everytime checking, if it doesn't exist: unless
Currently, my ListViews look like this: How can I achieve that Windows 7 native
Currently I do like this: IndexSearcher searcher = new IndexSearcher(lucenePath); Hits hits = searcher.Search(query);
Currently my WPF application imports a part like this [Import(typeof(ILedPanel)] public ILedPanel Panel {

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.