Sign in to follow this  
johnnyBravo

Winsock2,Question about using a socket as designated listener...

Recommended Posts

Hi, I'm using Winsock 2 with c++, asynchronous sockets. Anyway I was wondering, with all the tutorials they all use one socket as the designated listener that once receives connection requests it would call another socket from an array to accept the incoming connection. I am wondering is this what you are supposed to do. Because in the end wouldn't you just end up with a socket that will not be used? So should should I just have a socket or more listening, and accept connections so they are no longer listening, leaving the listening to be done by others? Because I am making a game that has 4 players and from a client/server launcher program it assigns the players how many people they have to connect to and how many listens they have to wait for. I'm not sure what that is called, that is everyone is atleast connected to someone else. So my game isn't really server based. So would it be better to have say if one person had to listen for 2 connections, to have 2 sockets listening waiting for a connection each? Thankyou.

Share this post


Link to post
Share on other sites
That is how it is supposed to go. You have your listening socket that listens for incoming connections and then your actual list of connection sockets that it passes the incoming connection to.

Yes, you are basically using up 1 socket to listen for those incoming connections, but it's 1 out of 65,536 sockets(roughly).

So you're fine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this