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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:45:51+00:00 2026-05-13T17:45:51+00:00

I am writing a server in linux that is supposed to serve an API.

  • 0

I am writing a server in linux that is supposed to serve an API.

Initially, I wanted to make it Multi-threaded on a single port, meaning that I’d have multiple threads working on various request received on a single port.

One of my friends told me that it not the way it is supposed to work. He told me that when a request is received, I first have to follow a Handshake procedure, create a thread that is listening to some other port dedicated to the request and then redirect the requested client to the new port.

Theoretically, it’s very interesting but I could not find any information on how to implement the handshake and do the redirection. Can someone help?


If I’m not wrong in interpreting your responses, once I create a multithreaded server with a main thread listening to a port, and creates a new thread to handle requests, I’m essentially making it multithreaded on a single port?

Consider the scenario where I get a large number of requests every second. Isn’t it true that every request on the port should now wait for the “current” request to complete? If not, how would the communication still be done: Say a browser sends a request, so the thread handling this has to first listen to the port, block it, process it, respond and then unblock it.

By this, eventhough I’m having “multithreads” , all I’m using is one single thread at a time apart from the main thread because the port is being blocked.

  • 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-13T17:45:51+00:00Added an answer on May 13, 2026 at 5:45 pm

    What your friend told you is similar to passive FTP – a client tells the server that it needs a connection, the server sends back the port number and the client creates a data connection to that port.

    But all you wanted to do is a multithreaded server. All you need is one server socket listening and accepting connections on a given port. As soon as the automatic TCP handshake is finished, you’ll get a new socket from the accept function – that socket will be used for communication with the client that has just connected. So now you only have to create a new thread, passing that client socket to the thread function. In your server thread, you will then call accept again in order to accept another connection.

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

Sidebar

Ask A Question

Stats

  • Questions 322k
  • Answers 322k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); byte[] bytes= encoding.GetBytes(stringData); May 14, 2026 at 12:53 am
  • Editorial Team
    Editorial Team added an answer You should apply the Docking or Anchoring techniques. http://www.codeproject.com/KB/mobile/MOB4DEVS03.aspx May 14, 2026 at 12:53 am
  • Editorial Team
    Editorial Team added an answer Try the following, worked for me in VS 2005. This… May 14, 2026 at 12:53 am

Related Questions

Here is where I am at presently. I am designing a card game with
I am writing a small application to get the various diagnostic parameter of Apache
I need to invoke tesseract OCR (its an open source library in C++ that
I am currently struggling with a side project I hope you can help me
I'm writing a web-server in Python as a hobby project. The code is targeted

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.