2 different ports connections on server

turbot_yu
turbot_yu used Ask the Experts™
on
It need to open a tcp server and accept 2 socket connection from 2 different port.

Originally, for one port socket server, it need

socket()
bind()
listen()
accept()

but for another connection from another port, does I need to repeat all the 4 steps again to create another tcp server waiting for the other connection.

Any suggestions, thx.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009
Commented:
If the server is listening on two different ports, then yes, you need to use those 4 functions again to set up a second listening socket.

If the server is listening on only one port, but can accept multiple connections, then just the 'accept' function needs to be called more than once (probably in a loop).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial