We help IT Professionals succeed at work.
Get Started

TCP Socket server handling multiple requests

sheepfarmer
sheepfarmer asked
on
2,398 Views
Last Modified: 2013-11-23
Morning,

I have a basic socket server up and running - it listens on port x, when it receives an external request it does some stuff with that connection, then it resets to handle the next request.

I want to make the socket server so that it can handle multiple requests at the same sometime.

Could I get some guidance on what techniques will be required for this.  In my mind, the following would seem relevent:
1. Creating a new tread for each incoming connection
2. Somehow passing off each new connection to another port (random) so that port x is freed up to await the next connection
3. Ensuring that the working code that does stuff with the external request is thread safe.

Is there anything else I should consider.

Thanks
SF
Comment
Watch Question
Sr. Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 4 Answers and 11 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE