Jump to content

  • Log In with Google      Sign In   
  • Create Account


Master server question (Winsock)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

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

#1 Anddos   Members   -  Reputation: 485

Like
0Likes
Like

Posted 04 November 2013 - 01:16 AM

If the master server handles all the ips that are listening for connections then if a listening 
server goes down it means you need to remove that server from the list,how would you achieve this 
if the ips are stored in a vector,how would you know which server just closed and that you need 
to remove it from the list?,so that when the clients do a refresh they dont see that server hosting any more.

:)

Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 6065

Like
0Likes
Like

Posted 04 November 2013 - 05:56 AM

store the server ip and the last time you heard from it in the vector instead, have servers notify the master server every 30 seconds or so and then simply drop or ignore servers from the vector if they have been silent for more than a minute.

 

Personally i wouldn't use a vector for this though, a map is probably better.


Edited by SimonForsman, 04 November 2013 - 05:58 AM.

I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#3 hplus0603   Moderators   -  Reputation: 5185

Like
0Likes
Like

Posted 04 November 2013 - 10:14 AM

Is there a TCP connection between the listening server and the master server?

If so, you can remove the listening server when the connection is closed (return 0 or -1 from recv())

 

However, if the network connection is broken, or the machine is powered off or hard-crashes, the connection will "stay alive" for a long time before it's detected as closed.

You can fix this by sending periodic messages in both directions on the connection, or by turning on SO_KEEPALIVE (although SO_KEEPALIVE by default also uses a very long timeout.)

 

To map from an IP address (or socket file handle) to a connection object, use the appropriate data structure for doing value look-ups based on key. 99 times out of 100, that's a hash table. (In C++, an unordered_map)


enum Bool { True, False, FileNotFound };




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS