Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to ban ip in the chatroom ?

How to ban ip in the chatroom ?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicssysadmintutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wangningyu
    wrote on last edited by
    #1

    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 !

    C I 2 Replies Last reply
    0
    • W wangningyu

      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 !

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      you could use a map, or a set, with the IP as key.

      image processing toolkits | batch image processing

      1 Reply Last reply
      0
      • W wangningyu

        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 Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        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!

        W 1 Reply Last reply
        0
        • I Iain Clarke Warrior Programmer

          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!

          W Offline
          W Offline
          wangningyu
          wrote on last edited by
          #4

          the vector and map like same as. what's the mean ?

          I 1 Reply Last reply
          0
          • W wangningyu

            the vector and map like same as. what's the mean ?

            I Offline
            I Offline
            Iain Clarke Warrior Programmer
            wrote on last edited by
            #5

            vector, map, and set and all stl containers. They do different jobs though! See these links: std::vector[^] std::map[^] std::set[^] I hope that helps - a bit, at least! Iain.

            I am one of "those foreigners coming over here and stealing our jobs". Yay me!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups