How to ban ip in the chatroom ?
-
The chatroom server app is used TCP WSAasyncSelect mode . I want ban some ip in the chatroom,let him doesn't connect the server. Now I use a vector list to save the ip, when someone connect ,it will traversal search . if in the black list, then call closesocket. But this is the low efficiency. Is there any other way? Thanks for you replay !
-
The chatroom server app is used TCP WSAasyncSelect mode . I want ban some ip in the chatroom,let him doesn't connect the server. Now I use a vector list to save the ip, when someone connect ,it will traversal search . if in the black list, then call closesocket. But this is the low efficiency. Is there any other way? Thanks for you replay !
you could use a map, or a set, with the IP as key.
-
The chatroom server app is used TCP WSAasyncSelect mode . I want ban some ip in the chatroom,let him doesn't connect the server. Now I use a vector list to save the ip, when someone connect ,it will traversal search . if in the black list, then call closesocket. But this is the low efficiency. Is there any other way? Thanks for you replay !
I imagine there's plenty of slow stuff going on, so traversing a vector would not be tooooooo bad - but you could a set if you'd like a more efficient way of testing if an item is in a "List" or not... http://www.cplusplus.com/reference/stl/set/[^] It's slower to add an item, but testing for existence will be faster than vector. And I'm sure people connect (and are accepting) a vast amount more than they are banned. Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
-
I imagine there's plenty of slow stuff going on, so traversing a vector would not be tooooooo bad - but you could a set if you'd like a more efficient way of testing if an item is in a "List" or not... http://www.cplusplus.com/reference/stl/set/[^] It's slower to add an item, but testing for existence will be faster than vector. And I'm sure people connect (and are accepting) a vast amount more than they are banned. Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
the vector and map like same as. what's the mean ?
-
the vector and map like same as. what's the mean ?