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. Knowing the connected client

Knowing the connected client

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • _ Offline
    _ Offline
    _8086
    wrote on last edited by
    #1

    client=accept(serv,(struct sockaddr*)&frm,&frmlen);

    This line gets the client that connects from a remote machine. Now how do we know from which machine did that connect? How do we get the machine name or IP address. Is there any function that gets in the SOCKET as input and returns IP address or Name?

    ---------------------------- 286? WOWW!:-O

    D 1 Reply Last reply
    0
    • _ _8086

      client=accept(serv,(struct sockaddr*)&frm,&frmlen);

      This line gets the client that connects from a remote machine. Now how do we know from which machine did that connect? How do we get the machine name or IP address. Is there any function that gets in the SOCKET as input and returns IP address or Name?

      ---------------------------- 286? WOWW!:-O

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      _8086 wrote:

      Now how do we know from which machine did that connect?

      client = accept(serv, (struct sockaddr *) &frm, &frmlen);
      char *clienthost = inet_ntoa(frm.sin_addr);
      int port = ntohs(frm.sin_port);


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      _ 1 Reply Last reply
      0
      • D David Crow

        _8086 wrote:

        Now how do we know from which machine did that connect?

        client = accept(serv, (struct sockaddr *) &frm, &frmlen);
        char *clienthost = inet_ntoa(frm.sin_addr);
        int port = ntohs(frm.sin_port);


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        _ Offline
        _ Offline
        _8086
        wrote on last edited by
        #3

        Thanks David.

        ---------------------------- 286? WOWW!:-O

        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