Greg Stark writes:
 > Just note that the IP address is not authenticated and thus is untrusted.
 > Whether this matters or not depends on what you are doing with it.
 > 
 > _____________________________________
 > Greg Stark
 > Ethentica, Inc.
 > [EMAIL PROTECTED]
 > _____________________________________

That's OK, I'm just using it for logging and to pass to CGI scripts
(I'm writing a web server.)  This is what I came up with (under
Windows 98/NT4):

  SOCKET s = BIO_get_fd(bio, NULL);
  struct sockaddr_in addr;
  int    addrSize = sizeof(addr);
  char*  addrStr;
  if (!getpeername(s, reinterpret_cast<sockaddr*>(&addr), &addrSize) &&
      (addrStr = inet_ntoa(addr.sin_addr)))
    strcpy(remoteAddr, addrStr);
  else throw 0;                 // Couldn't get remote IP address

-- 
Chris Madsen                                [EMAIL PROTECTED]
 ------- http://www.geocities.com/SiliconValley/Heights/3222/ -------
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to