|
-
Nov 21st, 2005, 06:38 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Blocking New Connections - Help Needed
pls can anyone tell me how to block new connections in winsock
-
Nov 22nd, 2005, 07:26 AM
#2
Re: Blocking New Connections - Help Needed
New connections to what? From what?
-
Nov 25th, 2005, 05:41 PM
#3
Thread Starter
Fanatic Member
Re: Blocking New Connections - Help Needed
i have a chat winsock app that must block new connections when a total of 12 connections have been established by 12 different ip.
-
Dec 5th, 2005, 03:23 PM
#4
Lively Member
Re: Blocking New Connections - Help Needed
I assume you've have to be using an array of Sockets for that - why can't you just keep note of how many are created, then abort accepting the connection once the limit has been reached?
I always setup a static array defined as socket objects, then create a second array of booleans that indicate if the corresponding location in the Socket array is in use. Then, I loop through my sockets and find empty places to create new ones. Likewise, I remove the socket when I'm done. In my case, I'd just count the number of Trues in my array of booleans to determine how many connections I have.
Good luck!
-
Dec 6th, 2005, 12:19 PM
#5
Addicted Member
Re: Blocking New Connections - Help Needed
I'm developing a chat application too. I work with serialized objects, wich are received and sent back from and to the server, respectively. What I do is really simple, I define an static var, wich is increased when a client connects to the server and decreased when he disconnects from it. I also keep a private const that contains number of users that will be accepted simultaneously. When you receive a new connection, the only thing you have to do is to check if static var is equal to private const. In that case you must say to the client that his try of connection has failed. And for doing that you will always have to first accept the socket, independently of the current number of user connected, and then do the condicional sentence.
It's just the way that I'm working with that.
I hope that you find it useful at least.
Regards!.
-
Dec 6th, 2005, 05:56 PM
#6
Thread Starter
Fanatic Member
Re: Blocking New Connections - Help Needed
i found a way out of it.
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|