View Full Version : get IP address and port of incoming connection
Elkvis
03-26-2008, 01:22 PM
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?
Elkvis
03-27-2008, 01:55 PM
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.
brewbuck
03-27-2008, 02:16 PM
How exactly are you calling BIO_get_conn_ip()?
Elkvis
03-27-2008, 02:53 PM
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:
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...
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....
Elkvis
03-31-2008, 03:07 PM
anyone have any ideas on this one?
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.