How to determine the clients IP it was calling through?

How to create a method that I return the ip of the clients connected to the server?

Ps. I use SynapseSuperTCPServer.

I try this, but not work.

function TNewService.GetIP:AnsiString;
var
tcpinfo: IROTCPTransport;
begin
Result := tcpinfo.ClientAddress;
end;

Roberto.

Hi,

in your service, add the event OnGetDispatchinfo and add this code:

var
tcpinfo: IROTCPTransport;
begin
if Supports( aTransport, IROTCPTransport, tcpinfo ) then
FClientIP := tcpinfo.ClientAddress;

{FClientIP is a string variable in my case defined in the class definition}

end;

Best Regards

Claudio

Thank you Claudio,

You can send you an example of how to use this event?

Roberto.

Hi Roberto,

yes of course.

I just created a simple sample with the wizard and added the code in the OnGetDispacthInfo event.

Let me know :wink:

Best Regards

Claudio

Hello Claudio.

Your example worked perfectly.

But their service is a remotedatamodule where you can set the event. But my service is a TRORemotable. How do I set this event ?

Roberto.

Hi Roberto,

yes you can, just add the IRODispatchNotifier interface to its declaration and provide an implementation for the method GetDispatchInfo.

read this in the wiki:

http://wiki.remobjects.com/wiki/IRODispatchNotifier_Interface

Best Regards

Claudio

Thank you Claudio …

It Worked …