Here's a snip of old code another WO developer shared with me many years back.  
It seems to work fine.  Someone may want to chime in on a newer or better 
method of handling this.

    /**
     * Returns the IP address of the client.
     * This should return accurate information whether in direct connect or
     * webserver deployment mode.
     * 
     * @return The IP address as a string.
     */
    public String clientIPAddress(WORequest inRequest)
        {
        Object ipAddress = null;
        if (inRequest != null)
            {
            ipAddress = inRequest.headerForKey("remote_addr");
            if (ipAddress == null)
                {
                ipAddress = inRequest.headerForKey("remote_host");
                if (ipAddress == null)
                    {
                    ipAddress = inRequest._remoteAddress();
                    if (ipAddress == null)
                        {
                        ipAddress = inRequest._originatingAddress();
                        if (ipAddress != null)
                            {
                            ipAddress = ((InetAddress) 
ipAddress).getHostAddress();
                            }
                        }
                    }
                }
            }
        return ipAddress == null ? "<address unknown>" : ipAddress.toString();
        }

-G

On Oct 23, 2010, at 9:33 AM, Farrukh Ijaz wrote:

> Hi,
> 
> Shouldn't request._remoteAddress() return client's IP instead of server id? 
> I'm debugging and in the header as well as using _remoteAddress(), I get the 
> server address.
> 
> How can I obtain client's address as part of WORequest?
> 
> Thanks,
> 
> Farrukh _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/george%40boxofficetickets.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to