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. WinSOCK bind function.

WinSOCK bind function.

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadmintutorial
4 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.
  • S Offline
    S Offline
    Soren Alsbjerg Horup
    wrote on last edited by
    #1

    I'm trying to create a server which accepts client connections. .... Address.sin_family = AF_INET; Address.sin_port = htons(1212); Address.sin_addr.s_addr = htonl(INADDR_ANY); IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address)); IntReturn = listen(Listen, 10); IntReturn = sizeof(RemoteAddress); Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn); ... Clients from any! ip can connect to my server on port 1212.. My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ? I thought about changing this line Address.sin_addr.s_addr = htonl(INADDR_ANY); to Address.sin_addr.s_addr = inet_addr("10.0.0.105"); but this does not work, am I doing something wrong? Thanks

    M R 2 Replies Last reply
    0
    • S Soren Alsbjerg Horup

      I'm trying to create a server which accepts client connections. .... Address.sin_family = AF_INET; Address.sin_port = htons(1212); Address.sin_addr.s_addr = htonl(INADDR_ANY); IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address)); IntReturn = listen(Listen, 10); IntReturn = sizeof(RemoteAddress); Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn); ... Clients from any! ip can connect to my server on port 1212.. My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ? I thought about changing this line Address.sin_addr.s_addr = htonl(INADDR_ANY); to Address.sin_addr.s_addr = inet_addr("10.0.0.105"); but this does not work, am I doing something wrong? Thanks

      M Offline
      M Offline
      markkuk
      wrote on last edited by
      #2

      Use a firewall. Winsock doesn't support connection filtering.

      S 1 Reply Last reply
      0
      • M markkuk

        Use a firewall. Winsock doesn't support connection filtering.

        S Offline
        S Offline
        Soren Alsbjerg Horup
        wrote on last edited by
        #3

        Well, thats not an option, since I'm using it on a LAN.

        1 Reply Last reply
        0
        • S Soren Alsbjerg Horup

          I'm trying to create a server which accepts client connections. .... Address.sin_family = AF_INET; Address.sin_port = htons(1212); Address.sin_addr.s_addr = htonl(INADDR_ANY); IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address)); IntReturn = listen(Listen, 10); IntReturn = sizeof(RemoteAddress); Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn); ... Clients from any! ip can connect to my server on port 1212.. My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ? I thought about changing this line Address.sin_addr.s_addr = htonl(INADDR_ANY); to Address.sin_addr.s_addr = inet_addr("10.0.0.105"); but this does not work, am I doing something wrong? Thanks

          R Offline
          R Offline
          Rickard Andersson20
          wrote on last edited by
          #4

          Get IP from the connected client. Check if the IP is an accepted IP and if it's an accepted/allowed IP then start sending datta etc. if not, just disconnect the socket. Rickard Andersson Here is my card, contact me later! UIN: 50302279 Sonork: 37318 Interests: C++, ADO, SQL, Winsock, 0s and 1s

          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