Getting IP-Adress

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting IP-Adress

OSon
Hi,

I build a server an I want to get the IP-adress of a client that connect
to the server. I tried this:

        client = BIO_pop(acc);
         
        SOCKET buffer;
        BIO_get_fd(client, &buffer);

        sockaddr* peername = NULL;
        int namelen;

        getpeername(buffer, peername, &namelen);


This code compiles an throws no error but the sockaddr struct ist filled
with bad pointers. Can anyone help me to find my mistakes?

Tank you very much.

OSon
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Getting IP-Adress

Richard Salz
>         sockaddr* peername = NULL;
>         int namelen;
>
>         getpeername(buffer, peername, &namelen);

Just like namelen, you have to allocate space:

        sockaddr peername
        namelen = sizeof peername;;
        getpeername(buffer, &perrname, &namelen);

--
SOA Appliance Group
IBM Application Integration Middleware


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Getting IP-Adress

OSon
Yes, it work's. Thank you very much!

Richard Salz schrieb:

>>        sockaddr* peername = NULL;
>>        int namelen;
>>
>>        getpeername(buffer, peername, &namelen);
>>    
>>
>
>Just like namelen, you have to allocate space:
>
>        sockaddr peername
>        namelen = sizeof peername;;
>        getpeername(buffer, &perrname, &namelen);
>
>  
>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]