Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

KalvinB

1400 connected then 900 using TCP/IP

This topic is 5835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I figured out how to get past the 64 socket limit with Winsock by redefining a single variable. Win2K Pro has no qualms with having it set to 32768. However, I''m running into a problem where after successfully connecting more than 1400 clients all sending messages a bunch are dropped by the server. To get that many connected I use a small app that connects 100 times (using my client class) and run it a bunch of times. Each instance sends off a message from each connection every second. When one of the connections gets kicked the whole program exits so fewer may actually be getting kicked by the server. Is there any logical reason for this happening? Watching the output window, the server starts stalling when it comes to processing messages with that many connections. Is it just too much for the server to handle (e.g. I need to make message processing more efficient)? Or is it a Winsock thing? Ben IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]

Share this post


Link to post
Share on other sites
Advertisement
I reckon 900 connections is a hell of a lot for any one machine to handle, but I've not done much other than 10 client one server networking.

Edit - you may want to check the memory usage per program. If you're allocating send or receive buffers, then the memory usage could get massive.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions


[edited by - siaspete on June 23, 2002 6:47:45 AM]

Share this post


Link to post
Share on other sites
Is the TCP or UDP? You might be filling up your receive buffers and UDP will start dropping packets when that happens (though TCP won''t)

There''s theoretically no limit on the number of connections you can process (at least, no hard-coded limit, it''s a matter of system resources and such)

Also, changing that #define thing is not a good idea, since it''s not very portable. If you''re planning on doing that, consider using a more efficient (though also non-portable) mechanism, like I/O completion ports.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
It's TCP.

I checked memory usage. At 1400 connections it was 4.5MB. After a few minutes it had kicked out all but 800.

I'll probably just write a simple lobby that hands out IPs and ports of open servers. That would allow for a simple seamless way to limit max connections without crippling the real server.

Fortunatly there's a lot more work to do before having to worry about that.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]


[edited by - KalvinB on June 23, 2002 7:28:04 AM]

Share this post


Link to post
Share on other sites
Well, what about CPU load? If you''re using select() (which I assume you are if you need to change a #define), this might be the reason - it doesn''t scale too well. I don''t know how WinSock implements the fd_set, but that could be a bottleneck.

cu,
Prefect

Return to the Shadows

Share this post


Link to post
Share on other sites
The server takes as much CPU power as it can get. select() is probably the bottleneck. I made a couple changes so that it keeps accepting connections until there are no more pending and then reads messages until the que is cleared. That helped remedy disconnects but the server stalled and crashed when I got above 1400 connections.

I/O Completion ports sound like the way to go but I''ve yet to find a tutorial on implementing them with TCP/IP.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]

Share this post


Link to post
Share on other sites
Why don''t you use UDP instead. It''s a pain in the @ss I know but it''s around specifically for these kind of problems. Read a book or an article on point-to-point data layer transfer (NOT ppp) and apply the exact same algorithm in a peer-to-peer manner with UDP.

TCP are slow and a hassle for routers to send. I wouldn''t be surprised if some home internet provider routers are limiting the number of simultaneous TCP connections on a single host.

Share this post


Link to post
Share on other sites
quote:
Original post by Coincoin
TCP are slow and a hassle for routers to send. I wouldn''t be surprised if some home internet provider routers are limiting the number of simultaneous TCP connections on a single host.


Eh, routers work with IP packets, so they don''t know anything about UDP or TCP. Sometimes they use the protocol field to give priority to various packet types (and to block others) but that''s it.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
Yup .. moving to UDP wont really help you here (especially if the data needs to arrive.. cuz then u just end up doing some method of insuring the data arrives which.. oh IS TCP )

anyway.. more to the point, I have just been doing a TCP IOCP class my self :-) so if you have any questions then send em my way -=lukejedikt@hotmail.com=- also do a search on this forum for IOCP ;-) I may even give out my source code if your interested in the hope that you could help me improve it in any way (thinking of making it open source). Its all bundled into a neat class too so you dont have to worry about things like thread handling etc :-)

~wrathgame
ps. im off for 1 week today on holiday so ill reply to any email after that

Share this post


Link to post
Share on other sites
I''m not using UDP because I would have to reinvent the TCP/IP wheel which would waste a significant portion of my time. My project doesn''t require fast packets but it requires they all arrive in tact and in order.

I don''t use Open Source code. I only take "Use it how you like but be nice enough to share any improvements" source. All the source I release is released without an official license.

"I wouldn''t be surprised if some home internet provider routers are limiting the number of simultaneous TCP connections on a single host."

Routers don''t hold or determine connections. All they do is direct traffic. The only determining factor of the maximum number of connections is the server computer.

I''ll keep looking into IOCP. The more I think about it though, the more it makes sense to just limit the max connections to around 1000 and run a lobby. The server could handle 10,000 connections I''m sure but the amount of game logic that would need to be processed would bring the CPU to a halt. It''s entirely possible to run multiple instances of the server on the same computer.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!