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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:36:07+00:00 2026-06-12T13:36:07+00:00

I am writing a multithreaded server application, in C (linux), that must listen to

  • 0

I am writing a multithreaded server application, in C (linux), that must listen to 2 different port numbers, say listen to port no 3000 and 4000, for different clients connecting to it to serve different functionality (actual function is executed by a worker thread, main thread runs indefinitely and spawns of new workers upon new connections). I am not sure if select would work here as we can have multiple socket connections but all associated with same port number. I tried sequentially binding to sock_1 and sock_2. When I run client_1, everything works as expected. But, when I run client_2, I get an error on connect() from client side. If select() can be used here, please let me know how to do it. Any help much appreciated ! Thanks !

(P.S sock_1 refers to port no 3000 and sock_2 refers to port no 4000, client_1 refers to client thats seeking service from port 3000 and client_2 refers to client seeking service from same server from port no 4000)

  • 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-12T13:36:08+00:00Added an answer on June 12, 2026 at 1:36 pm

    You have totally misunderstood socket and port, these two are different things.
    A port can have multiple sockets. but you can bind your listing socket(passive socket) to only a single port.
    Before going any further read this

    If you want that your application listen on two different ports, have you bind two different sockets with it.

    For a Quick reference a select in single process can only have upto 1024 socket descriptors.
    So if you are using a single process model then a select can only handle 1024 connections.
    Also read C10k problem see what suits your need.

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

Sidebar

Related Questions

I'm writing a small multithreaded client-side python application that contains a small webserver (only
I am writing a multithreaded client that uses an IO Completion Port. I create
I am writing a server in linux that is supposed to serve an API.
I am writing a multithreaded C++ (Linux) SOAP client to interface with the Betfair
I am writing a multithreaded socket application in Python using the socket module. the
I'm writing a multi-threaded server application in Java. Everything works fine , but there's
So I am writing a multithreaded server which takes in as an input the
Is I am looking at writing a multithreaded tcp server using boost ASIO. I
I have the following problem: I have a multithreaded server-side application, where every request
I have a multithreaded python application that does a bunch of processing on files.

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.