Thread: get IP address and port of incoming connection

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445

    get IP address and port of incoming connection

    I have a server application, to which I'm adding SSL support with OpenSSL. is there a way to get the IP address and port of the incoming connection from the SSL structure somehow, and if not, how do I get it when I only know the socket descriptor number, and I don't have access to the sockaddr_in structure that was used to create it?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    does anyone have any ideas on this one? I have done all the research I can, and have found nothing but dead ends. I have tried BIO_get_conn_ip(), which always fails for some reason, and I have done extensive googling for other possible answers, with no useful results.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    How exactly are you calling BIO_get_conn_ip()?

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by brewbuck View Post
    How exactly are you calling BIO_get_conn_ip()?
    I've tried it a couple of different ways. the first way was to call SSL_get_rbio() to get the BIO structure, and then the following:

    in the function that handles communication with the client:
    Code:
    char* ip_bin = NULL;
    ip_bin = BIO_get_conn_ip(rbio);
    if (ip_bin) ...print ip address here...
    else ...print failure message....
    the other way I tried was the following:

    after accepting and forking, and before handing the BIO off to the SSL object...
    Code:
    char* ip_bin = NULL;
    sbio = BIO_new_socket(sock, BIO_NOCLOSE);
    ip_bin = BIO_get_conn_ip(sbio);
    if (ip_bin) ...print ip address here...
    else ...print failure message....
    not sure what else to try....

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    anyone have any ideas on this one?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concurrent chat, Sockets
    By jakemott in forum Linux Programming
    Replies: 6
    Last Post: 11-29-2008, 05:41 PM
  2. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 01:58 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM