Thread: Socket's

  1. #1
    C++ elitesyntax's Avatar
    Join Date
    Mar 2004
    Posts
    12

    Socket's

    if you have a socket handle how can you know the IP of it in C or C++
    Last edited by elitesyntax; 03-28-2004 at 08:04 PM.
    Compiler Gcc

  2. #2
    sockets mad
    Join Date
    Mar 2002
    Posts
    126
    sockaddr structure will hold all that information. Read up on it.

    When you call the accept() function the second parameter (i think) is a pointer to a sockaddr structure to fill with the information regarding the connecting device.

    -Dan

  3. #3
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    Quote Originally Posted by codec
    sockaddr structure will hold all that information. Read up on it.

    When you call the accept() function the second parameter (i think) is a pointer to a sockaddr structure to fill with the information regarding the connecting device.

    -Dan
    I think that he is referring to,"How can I, with just a socket handle, get the ip address"....


    to be honest, I dont know, after looking through some unix man pages, I cannot find any function that will return the address of the other side of a socket.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Under Win32 platform, definitely. I am not familiar on the UNIX platform.

    Kuphryn

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    getpeername() - Available on all platforms.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Best way to poll sockets?
    By 39ster in forum Networking/Device Communication
    Replies: 3
    Last Post: 07-22-2008, 01:43 PM
  2. Cross platform sockets
    By zacs7 in forum Networking/Device Communication
    Replies: 5
    Last Post: 06-27-2007, 05:16 AM
  3. multiple UDP sockets with select()
    By nkhambal in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-17-2006, 07:36 PM
  4. Raw Sockets and SP2...
    By Devil Panther in forum Networking/Device Communication
    Replies: 11
    Last Post: 08-12-2005, 04:52 AM
  5. Starting window sockets
    By _Cl0wn_ in forum Windows Programming
    Replies: 2
    Last Post: 01-20-2003, 11:49 AM