Jump to content



Thread per client? Headless server?

  • You cannot reply to this topic
7 replies to this topic

#1 Kono   Members   -  Reputation: 99

Like
-1Likes
Like

Posted 06 February 2011 - 02:43 PM

Hey there.



I'm trying to build a server for my humble online game in C++ right now,


and I ran into a problem.



From what I can tell, there are several ways to manage clients and read data from them.


I'm looking for a convenient way to do so, without the need of creating a window (for asynchronous data management i.e)


and I also need a way that will be efficient and stable.



Iv'e tried to read data from client in a thread-per-client way and it didn't seem to my likings, is there any other


traditional way to do so? If so, I'd be happy if you pointed me to a guide or whatever.



Thanks in advance, Tamir Atias



[restored deleted content --rip-off]



Ad:

#2 KulSeran   Members   -  Reputation: 1202

Like
0Likes
Like

Posted 06 February 2011 - 02:47 PM

You could look into packages that handle this for you, like RakNet.

#3 Kono   Members   -  Reputation: 99

Like
0Likes
Like

Posted 06 February 2011 - 02:56 PM

View PostKulSeran, on 06 February 2011 - 02:47 PM, said:

You could look into packages that handle this for you, like RakNet.
I know about those layers, I really want to build my own one.

#4 BeerNutts   Members   -  Reputation: 241

Like
0Likes
Like

Posted 07 February 2011 - 08:41 AM

Maybe I don't really understand what you're asking, but will select() not work for you? You could have select() operating on all the client sockets in one thread, and pass the data from the clients to your main thread via messaging.

I would think you've already looked at that option, but, it's the simplest way of asynchronously gathering data from any number of clients and sending to a control thread.

View PostKono, on 06 February 2011 - 02:43 PM, said:

Hey there.

I'm trying to build a server for my humble online game in C++ right now,
and I ran into a problem.

From what I can tell, there are several ways to manage clients and read data from them.
I'm looking for a convenient way to do so, without the need of creating a window (for asynchronous data management i.e)
and I also need a way that will be efficient and stable.

Iv'e tried to read data from client in a thread-per-client way and it didn't seem to my likings, is there any other
traditional way to do so? If so, I'd be happy if you pointed me to a guide or whatever.

Thanks in advance, Tamir Atias.

Moderators/Administrators: Sorry for posting this in the wrong forum, can anyone please move this?

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#5 Kono   Members   -  Reputation: 99

Like
0Likes
Like

Posted 13 February 2011 - 01:36 PM

View PostBeerNutts, on 07 February 2011 - 08:41 AM, said:

Maybe I don't really understand what you're asking, but will select() not work for you? You could have select() operating on all the client sockets in one thread, and pass the data from the clients to your main thread via messaging.

I would think you've already looked at that option, but, it's the simplest way of asynchronously gathering data from any number of clients and sending to a control thread.

View PostKono, on 06 February 2011 - 02:43 PM, said:

Hey there.

I'm trying to build a server for my humble online game in C++ right now,
and I ran into a problem.

From what I can tell, there are several ways to manage clients and read data from them.
I'm looking for a convenient way to do so, without the need of creating a window (for asynchronous data management i.e)
and I also need a way that will be efficient and stable.

Iv'e tried to read data from client in a thread-per-client way and it didn't seem to my likings, is there any other
traditional way to do so? If so, I'd be happy if you pointed me to a guide or whatever.

Thanks in advance, Tamir Atias.

Moderators/Administrators: Sorry for posting this in the wrong forum, can anyone please move this?

So basically, when there is data available for reading, I need to inform the client with the same socket about it?

Thanks for you answer.






#6 rip-off   Moderators   -  Reputation: 2477

Like
0Likes
Like

Posted 20 February 2012 - 03:24 AM

Please do not delete content in threads. The thread will continue to exist in case there is any additional discussion required on the subject.

I cannot find the original title so I've given it one based on the original post. I've also moved it to the appropriate forum.

#7 hplus0603   Moderators   -  Reputation: 1800

Like
0Likes
Like

Posted 20 February 2012 - 06:03 PM

The FAQ for the networking forum is a good place to look for this information, too!
enum Bool { True, False, FileNotFound };

#8 wodinoneeye   Members   -  Reputation: 122

Like
0Likes
Like

Posted 24 February 2012 - 01:37 AM

View PostKono, on 06 February 2011 - 02:43 PM, said:

Hey there.


I'm trying to build a server for my humble online game in C++ right now,

and I ran into a problem.

From what I can tell, there are several ways to manage clients and read data from them.

I'm looking for a convenient way to do so, without the need of creating a window (for asynchronous data management i.e)

and I also need a way that will be efficient and stable.

Iv'e tried to read data from client in a thread-per-client way and it didn't seem to my likings, is there any other

traditional way to do so? If so, I'd be happy if you pointed me to a guide or whatever.

Thanks in advance, Tamir Atias

[restored deleted content --rip-off]



Its prefered not to use thread per client connection because of the thread switching overhead and you will
have to interlock the game data to prevent the threads from doing partial writes before being interrupted.

select() with a single thread will self synchronize the network operations (you still may need to do some interlocks with a main game thread)
--------------------------------------------Ratings are Opinion, not Fact






We are working on generating results for this topic
PARTNERS