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. Getting IP from client socket

Getting IP from client socket

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelp
2 Posts 2 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
    s_k
    wrote on last edited by
    #1

    Hi, I am working on FTP server and I need to manage IP Access. How can I get IP address from client socket which I accepted ?? And second question: dont you have/know any reliable and tested mechanism for providing IP Access restriction (eg. IP 200.100.50.25 cant access our server between 21.8.2002 23:00 and 22.8.2002 12:30) ??? I chiefly mean the format for saving these rules and for reading them (from textfile or whatever)... Any help will be appreciated !!! Thanks, Standa. Celebrate Mr. Cesilko!

    B 1 Reply Last reply
    0
    • S s_k

      Hi, I am working on FTP server and I need to manage IP Access. How can I get IP address from client socket which I accepted ?? And second question: dont you have/know any reliable and tested mechanism for providing IP Access restriction (eg. IP 200.100.50.25 cant access our server between 21.8.2002 23:00 and 22.8.2002 12:30) ??? I chiefly mean the format for saving these rules and for reading them (from textfile or whatever)... Any help will be appreciated !!! Thanks, Standa. Celebrate Mr. Cesilko!

      B Offline
      B Offline
      Bubba2146
      wrote on last edited by
      #2

      s_k wrote: How can I get IP address from client socket which I accepted ?? With Berkeley sockets you need to pass a sockaddr_in struct to your accept() call like so: struct sockaddr_in their_addr; /* connector's address information */ /* create a socket and call bind() and listen() */ sin_size = sizeof(struct sockaddr_in); new_fd = accept(sockfd, &their_addr, &sin_size); Upon connection you can read the values from the their_addr struct and get what you need. As for your other question I personally can't answer it in the context of a forum post. I would just look at how other programs handle rules like that for guidance. It's the kind of thing you can make as complex as you want, but I would really strive for simplicity to reduce logic errors.

      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