Search code examples
delphiemsrad-server

How to get client's IP address in Delphi RAD Server?


I have created a resource with GetItem(). RAD server calls GetItem() when the URL is accessed. Everything works.

The GetItem() procedure has 3 parameters:

procedure GetItem(const AContext: TEndpointContext; 
  const ARequest: TEndpointRequest; 
  const AResponse: TEndpointResponse);

I have been through each of the classes looking for the client's IP address. The only IP I found is my server's own host IP, which is not useful.

Does RAD server make this information available? I am using Delphi 10.2 Architect.

I have been through the library reference documentation. I have read through the PDFs that Embarcadaro published on creating a RAD server. I have tried searching the question on Google and Bing using different phrases.

I have written code to explore the different properties of the EMS classes.

I was expecting to find a property that contained the client's IP address, but I cannot find it.


Solution

  • Does RAD server make this information available?

    In Delphi 11 and later, you can use the TEndpointRequest.ClientHost property.

    Unfortunately, that property did not exist yet in Delphi 10.2. AFAIK, there is no other way to get the client IP in that version.