Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread How can Client application determine its own IP address
Fri, Nov 14 2008 11:11 PMPermanent Link

Tony Pomfrett
Hi,

I need my client application to be able to query it's remote server and have the server return the client application's IP address to the client
application. Alternatively, can the client application query the computer it is running on and find out it's IP address. Any suggestions?

Thanks,
Tony
Sat, Nov 15 2008 4:08 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tony,

<< I need my client application to be able to query it's remote server and
have the server return the client application's IP address to the client
application. Alternatively, can the client application query the computer it
is running on and find out it's IP address. Any suggestions? >>

The latter is what you want.  Just use this TDBISAMSession method:

     function GetRemoteSessionInfo(SessionNum: Integer;
                                   var SessionID: Integer;
                                   var CreatedOn: TDateTime;
                                   var LastConnectedOn: TDateTime;
                                   var UserName: String;
                                   var UserAddress: String;
                                   var Encrypted: Boolean;
                                   var LastUserAddress: String): Boolean;

http://www.elevatesoft.com/manual?action=mancompmethod&id=dbisam4&product=d&version=7&comp=TDBISAMSession&method=GetRemoteSessionInfo

Match the SessionID returned against the TDBISAMSession.CurrentRemoteID
property:

http://www.elevatesoft.com/manual?action=mancompprop&id=dbisam4&product=d&version=7&comp=TDBISAMSession&prop=CurrentRemoteID

When you get a match, you've found the current session.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Nov 15 2008 4:51 PMPermanent Link

Tony Pomfrett
Hi Tim,

I did see the GetRemoteSessionInfo function in the manual, but the disclaimer made me think it would not be suitable:

"Note
This method is only valid for encrypted remote sessions connected as an administrator to the administration port on a database server."


At present, my client application does not connect as an administrator to the administration port - will it now need to do so, just to find out the IP address?
Also, I'm assuming this method requires me to cycle through values of SessionNum from 1 to MaxSessionCount. This is potentially 100 remote calls to the server. It just doesn't seem efficient. Am I missing something here?

I have been using a procedure for the last couple of years which calls www.whatsmyip.com and scrapes the IP address from the returned data. Unfortunately, this site is sometimes slow to respond and the local computer's antivirus program
can also cause delays so that the procedure times out.


Thanks,
Tony.



"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Tony,

<< I need my client application to be able to query it's remote server and
have the server return the client application's IP address to the client
application. Alternatively, can the client application query the computer it
is running on and find out it's IP address. Any suggestions? >>

The latter is what you want.  Just use this TDBISAMSession method:

     function GetRemoteSessionInfo(SessionNum: Integer;
                                   var SessionID: Integer;
                                   var CreatedOn: TDateTime;
                                   var LastConnectedOn: TDateTime;
                                   var UserName: String;
                                   var UserAddress: String;
                                   var Encrypted: Boolean;
                                   var LastUserAddress: String): Boolean;

http://www.elevatesoft.com/manual?action=mancompmethod&id=dbisam4&product=d&version=7&comp=TDBISAMSession&method=GetRemoteSessionInfo

Match the SessionID returned against the TDBISAMSession.CurrentRemoteID
property:

http://www.elevatesoft.com/manual?action=mancompprop&id=dbisam4&product=d&version=7&comp=TDBISAMSession&prop=CurrentRemoteID

When you get a match, you've found the current session.

--
Tim Young
Elevate Software
www.elevatesoft.com
Sat, Nov 15 2008 11:29 PMPermanent Link

"Robert"

"Tony Pomfrett" <tonyp@aline.com.au> wrote in message
news:8D500990-C8B1-4010-8AA1-629E51D15F31@news.elevatesoft.com...
> Hi,
>
> I need my client application to be able to query it's remote server and
> have the server return the client application's IP address to the client
> application. Alternatively, can the client application query the computer
> it is running on and find out it's IP address. Any suggestions?
>

why ask the server? just get it at the workstation. google ip address delphi
you'll get tons of examples you can just about copy and paste. here's one

http://www.delphitricks.com/source-code/internet/get_your_own_ip_address.html

Robert
> Thanks,
> Tony
>

Mon, Nov 17 2008 4:19 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tony,

<< I did see the GetRemoteSessionInfo function in the manual, but the
disclaimer made me think it would not be suitable:

"Note
This method is only valid for encrypted remote sessions connected as an
administrator to the administration port on a database server."

At present, my client application does not connect as an administrator to
the administration port - will it now need to do so, just to find out the IP
address? >>

You can also use a server-side procedure to do so, which will eliminate all
of that and allow you to return the IP address quickly.

I would give you a way to do so directly via the client socket that we use
for the session, but the object isn't exposed so there's no way to allow
access to it without modifying the source code to the engine itself.

Of course, I can always put this down as an enhancement request also, if you
would like.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Nov 17 2008 5:30 PMPermanent Link

"Robert"

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:F21F2DB3-F1AA-4FFE-BA12-A896B7F3A566@news.elevatesoft.com...
>
> You can also use a server-side procedure to do so, which will eliminate
> all of that and allow you to return the IP address quickly.
>

Am I missunderstanding the quesion? Why even go to the server to get your
own IP address?

Robert

Tue, Nov 18 2008 8:15 AMPermanent Link

Tony Pomfrett
Thanks Tim & Robert,

The reason why I looked at obtaining the IP address from the server is because I had seen the IP addresses displayed in the server administration program and so thought it might be easily done.

There probably is no reason why I can't get the IP address from the client application as long as whatever code I use works for both XP and Vista.

Tony.
Tue, Nov 18 2008 2:20 PMPermanent Link

"Jeff Cook"
Tony Pomfrett wrote:

> Thanks Tim & Robert,
>
> The reason why I looked at obtaining the IP address from the server
> is because I had seen the IP addresses displayed in the server
> administration program and so thought it might be easily done.
>
> There probably is no reason why I can't get the IP address from the
> client application as long as whatever code I use works for both XP
> and Vista.
>
> Tony.

I have the following code in my splash screen which uses the IdIPWatch
component on the "Indy Misc" tab in D6.  Seems to be fine for Vista et
al.

procedure TSplashForm.FormCreate(Sender: TObject);
begin
    {Some screen values come from Project | Options -> VersionInfo }
 ProductName.Caption := Common.GetVersionInfoByKey('ProductName');
 Version.Caption := 'Version - ' +
Common.GetVersionInfoByKey('FileVersion')
   + ',  DBISAM - ' + DummyQuery.EngineVersion;
 IdIPwatch.Active := TRUE;
 IdIpwatch.ForceCheck;
 if IdIpWatch.CurrentIP <> '' then
   Version.Caption := Version.Caption + ', IP ' + IdIpwatch.CurrentIP;
 EMail.Caption := 'Email: ' + Common.GetVersionInfoByKey('Email');
 URL.Caption := Common.GetVersionInfoByKey('URL');
 Slogan.Caption := 'Perfection is a pursuit, not a destination.';
end;

--
Jeff Cook
Aspect Systems Ltd
www.aspect.co.nz
+
Joan and Jeff Cook
The Cooks Oasis
www.cookislandsoasis.com
Tue, Nov 18 2008 2:38 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Robert,

<< Am I missunderstanding the quesion? Why even go to the server to get your
own IP address? >>

Well, the issue is does he want the IP address that the server is seeing, or
the local IP address from the OS.  I assumed the former, which is why I gave
the answer that I did.

For example, my IP address on my machine is 192.168.0.5, but my IP address
to everyone in the outside world is 64.65.248.118 (our T1 router address).

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Nov 22 2008 7:30 AMPermanent Link

Tony Pomfrett
Tim,

You are correct. It is the external IP address I need.

Tony.
Page 1 of 2Next Page »
Jump to Page:  1 2
Image