Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411490 Posts in 69371 Topics- by 58428 Members - Latest Member: shelton786

April 25, 2024, 02:17:42 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)c++ socket accept, list of connected clients
Pages: [1]
Print
Author Topic: c++ socket accept, list of connected clients  (Read 528 times)
mymot
Level 0
*


View Profile
« on: May 06, 2018, 11:33:26 AM »

Hello, i have a few question about socket in c++!
First question, let's say that he writes a server for the game in which he will play 200 people at once, but accept is blocked because he already serves one client, how to deal with it?
Second question, how to download a list of all currently connected clients, so that you can then send a package to everyone?
Logged
Daid
Level 3
***



View Profile
« Reply #1 on: May 06, 2018, 11:58:28 AM »

You can use non-blocking sockets to have the accept() call not blocking, or use select() to find out which socket has data available, the listen socket indicates data available on select when there is a new connection.

For the 2nd part, you need to keep track of all the connected sockets yourself.
Logged

Software engineer by trade. Game development by hobby.
The Tribute Of Legends Devlog Co-op zelda.
EmptyEpsilon Free Co-op multiplayer spaceship simulator
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic