Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 9 Monaten, 2 Wochen
Letzter Beitrag:
vor 9 Monaten, 1 Woche
Beteiligte Autoren:
Sammy Broeders, Fabrice Harari, Arie

Client/server database change path

Startbeitrag von Sammy Broeders am 11.02.2017 10:40

Hello all,

I use the HF client/server database with a local server. When the user is with his laptop in the local network i use the computername of the server as path but when the user is out of the local network the path has to be the public ip adres. How can i change this automaticly, so when there is no connection with the computername it wil change to the public ip adres.

Thanks,
Sammy

Antworten:

Re: Client/server database change pat

Hi Sammy,

the simplest code would be to :
- try to connect with the computer name
- catch the error (herror, when exception, etc)
- if the error means that you are outside
- try to connect with the IP

Depending if the user is mostly in the office or out, you may want to invert the order (IP first, then name) or even remember the last one working (in an ini file) and start with it.

Best regards

von Fabrice Harari - am 11.02.2017 11:48

Re: Client/server database change pat

Fabrice,

Thanks for the reply.
With herror or when exception or something i don`t receive any error.

von Sammy Broeders - am 11.02.2017 12:02

Re: Client/server database change pat

Is there a code to find the public ip adres? If so, that wil make it easy!

von Sammy Broeders - am 14.02.2017 17:12

Re: Client/server database change pat

Hi

if you don't receive any error, then you are connected... it's magic that way...

Best regards

von Fabrice Harari - am 14.02.2017 18:44
Sammy,

I would use the public AP address always. If you are lucky the router is smart enough to route calls from the local netwerk directly to the destination inside your network, thus bypassing the outside route. Then you keep the local network speed. Otherwise you may be able to add a NAT rule to do this, but I'm not an expert on that one.

If you don't have a static WAN ip you could make a http request to http://checkip.dyndns.org/
It will return the wan ip as a simple string like
Current IP Address: 123.123.123.123

von Arie - am 14.02.2017 19:00
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.