Kae Cyphet
Kae Cyphet

Reputation: 185

Massive holding open of TCP/IP sockets

I would like to create a server infrastructure that allows 500 clients to connect all at the same time and have an indefinite connection. The plan is to have clients connect to TCP/IP sockets on the server and have them stay connected, with the server sending out data to clients randomly and clients sending data to the server randomly, similar to a small MMOG, but with scarcely any data. I came up with this plan in comparison to TCP polling every 15-30 seconds from each client.

My question is, in leaving these connections open, will this cause a massive sum of server bandwidth usage at idle? Is this the best approach without getting into the guts of TCP?

Upvotes: 3

Views: 462

Answers (2)

Brian White
Brian White

Reputation: 8746

TCP uses no bandwidth when idle, except maybe a few bytes every so often (default is 2 hours) if "keep-alive" is enabled.

500 connections is nothing, though epoll() is a good choice to reduce system overhead. 5000 connections might start to become an issue.

Upvotes: 1

GolezTrol
GolezTrol

Reputation: 116140

Bandwidth isn't your major concern, but there's a limit to the number of connections you can have open (though it is quite high).

But if polling every 15 seconds would be fast enough, I'd consider it a waste to keep the connection open.

Upvotes: 0

Related Questions