🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Ghost Connections

Started by
4 comments, last by Shannon Barber 22 years, 4 months ago
I start up a server, and set it up to accept 6 connections. I launch six clients and connect. My test program then chatters inanely at max speed with every client. All six connect and start receiving data. When I start a seventh client and attempt to connect - it (appears) to succeed to the client. WSAEnumNetworkEvents returns a connection code of 0, but the server never processes an accept for it (I only issue six async accept request). So, what am I doing wrong now? Is the server always suppose to issue accept request, and close the connection if/when it reaches it''s max connection count? Magmai Kai Holmlor "Oh, like you''ve never written buggy code" - Lee
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
I always accept the connection (except when the address is banned). This way I can send a message back to the client informing them that the server is full. I don''t think you can send data if the server hasn''t accepted the client? I guess it just depends if you want to formally notify the client.
Do you close the listening socket after 6 connects? How are you limiting that?
Windows networking will accept X connections at a time, but it will queue extras up for use after your server closes an existing connection.

You need to accept, say, 7, and then just use the seventh to send an error and disconnect.
I''m using the asycronous AcceptEx function, and I thought that the client would time-out/give-up if the server never processed the accept call.

I changed it so that it accepts one additional connection and closes the receive socket.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
The system is automatically accepting the connection through the server socket that you bound. It's a common misconception that executing accept() causes the client's connect() call to complete. In reality, it's the listen() call on the server socket that tells the system to do this automatic connecting. Winsock will buffer a certain number of connection requests (the suggested limit is one of the parameters to listen()) before refusing client connection attempts.

There's no way to tell a socket to stop listening, so if you really don't want to accept more connections, you just have to destroy the server socket (and recreate it later if you need to allow more clients to connect).


--
Eric

[edit] Bad wording.


Edited by - ekenslow on February 13, 2002 10:43:47 PM
-- Eric

This topic is closed to new replies.

Advertisement