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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:24:13+00:00 2026-06-15T14:24:13+00:00

So here is my scenario: I read from a socket and based on the

  • 0

So here is my scenario:
I read from a socket and based on the contents on the packet i put the packet into an appropriate queue. So if i have 10 queues there will be 10 if- else -ifs or 10 cases of a switch statement to select the proper queue. So, there can be atmost 10 comparisons.

Another way could be to ask the broadcaster/server to broadcast on 10 different ports where feed from each port will have packets for a single specific queue, on my end i can listen to each socket through a saperate thread(Or i can use a thread pool if the traffic on certain ports is less/non-uniform). So that now i dont have to select which queue the packet belongs to but now the phenomenon of conext switch is introduced.

From here my intelligence and technical knowledge prevent me going further.
Any enligtenment over which approach will perform better?

  • 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-06-15T14:24:14+00:00Added an answer on June 15, 2026 at 2:24 pm

    It is a personal choice. If the traffic is adequate or less than obviously the first approach is better. It is thread-safe, thanks to thread confinement. Easier to maintain. The only issue is that – if an extra port is added then you will have to modify the code for an extra if clause.

    But under heavy traffic, this might be better. Lesser packets will be lost if the buffer is full. Might perform better depending upon the number of cores but again can be buggy if not executed well.

    If I were you, I would have gone ahead with the first one. Keep it simple.

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

Sidebar

Related Questions

Here's the scenario: ThreadA is going to read from some socket, and write data
Here's the scenario - I have a C# application that reads from a COM
here i have written a window service, it job is to read files from
Here is my scenario: I have two MySQL tables: Categories (columns: id, category) Items
Here's the scenario: I have a public repo A . Bob forks A ,
Here's the scenario I anticipate: I have an app written in PHP which has
Here's the scenario: I have a multi threaded java web application which is running
I have spring application and using property file want to read the values from
Here's the scenario: Platform: VS2005 and language is VC++ Situation: There's just 1 assembly
Here is the scenario. I have an application which writes a configuration file in

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.