How to get the IP address of the 4D web server within 4D?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the IP address of the 4D web server within 4D?

KirkBrooks
I thought I saw this recently but I can't find it now - given a copy of 4D
running the web server how can I get the IP address it's listening to?

I thought WEB GET OPTION would do it but it doesn't dynamically (it only
seems to return whatever value WEB SET OPTION installed).

Thanks
--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

Balinder Walia
Kirk,

You want *Get database parameter *command.

The selector 16 (IP Address to listen) lets you get the IP address on which
the 4D Web server receives HTTP requests. The following example splits up
the hexadecimal value:

   *C_LONGINT <http://www.4d.com/jp/docs/CMU/CMU00283.HTM>*($a;$b;$c;$d)
   *C_LONGINT <http://www.4d.com/jp/docs/CMU/CMU00283.HTM>*($addr)
   $addr:=*Get database parameter*(*IP Address to listen*)
   $a:=($addr>>24)&0x000000ff
   $b:=($addr>>16)&0x000000ff
   $c:=($addr>>8)&0x000000ff
   $d:=$addr&0x000000ff


On 15 January 2017 at 19:48, Kirk Brooks <[hidden email]> wrote:

> I thought I saw this recently but I can't find it now - given a copy of 4D
> running the web server how can I get the IP address it's listening to?
>
> I thought WEB GET OPTION would do it but it doesn't dynamically (it only
> seems to return whatever value WEB SET OPTION installed).
>
> Thanks
> --
> Kirk Brooks
> San Francisco, CA
> =======================
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

KirkBrooks
Hey Bal,
I think this is reading the same resource as WEB GET OPTION. For instance,
since I have 'set' a particular IP to listen so both of them return zero.
The server is actually available at 192.168.1.3 or localhost.

On Sun, Jan 15, 2017 at 1:51 PM, Balinder Walia <[hidden email]>
wrote:

> You want *Get database parameter *command.
>
>
--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

Balinder Walia
Ah! That's no good. What about one of the parameters in OWC? Does 0 means
it is listening on all available IPs?
On Sun, 15 Jan 2017 at 23:25, Kirk Brooks <[hidden email]> wrote:

> Hey Bal,
>
> I think this is reading the same resource as WEB GET OPTION. For instance,
>
> since I have 'set' a particular IP to listen so both of them return zero.
>
> The server is actually available at 192.168.1.3 or localhost.
>
>
>
> On Sun, Jan 15, 2017 at 1:51 PM, Balinder Walia <[hidden email]>
>
> wrote:
>
>
>
> > You want *Get database parameter *command.
>
> >
>
> >
>
> --
>
> Kirk Brooks
>
> San Francisco, CA
>
> =======================
>
> **********************************************************************
>
> 4D Internet Users Group (4D iNUG)
>
> FAQ:  http://lists.4d.com/faqnug.html
>
> Archive:  http://lists.4d.com/archives.html
>
> Options: http://lists.4d.com/mailman/options/4d_tech
>
> Unsub:  mailto:[hidden email]
>
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

Keisuke Miyako
according to the docs (ignore the french constant names, it must be a silly bug)

it is now recommended to use

WEB GET OPTION
http://doc.4d.com/4Dv16/4D/16/WEB-GET-OPTION.301-3036901.en.html

instead of

Get database parameter
http://doc.4d.com/4Dv16/4D/16/Get-database-parameter.301-3036262.en.html

as of the OWC parameters,
I think they simply indicate the actual address used.

in recent versions,
127.0.1 could be represented in an IPv6-ish format,
so you just need to take care of that.

> 2017/01/16 9:10、Balinder Walia <[hidden email]> のメール:
>
> Ah! That's no good. What about one of the parameters in OWC? Does 0 means
> it is listening on all available IPs?



宮古 啓介
セールス・エンジニア

株式会社フォーディー・ジャパン
〒150-0043
東京都渋谷区道玄坂1-10-2 渋谷THビル6F
Tel: 03-6427-8441
Fax: 03-6427-8449

[hidden email]
www.4D.com/JP

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

KirkBrooks
Hi Miyako,

On Sun, Jan 15, 2017 at 4:54 PM, Keisuke Miyako <[hidden email]>
wrote:

> according to the docs (ignore the french constant names, it must be a
> silly bug)
>
> it is now recommended to use
>
> WEB GET OPTION
> http://doc.4d.com/4Dv16/4D/16/WEB-GET-OPTION.301-3036901.en.html
>

​Yes, ​
I thought WEB GET OPTION would do
​that
 but it seems to return whatever value WEB SET OPTION installed
​. As I mentioned I've got an instance of web server running. Executing


C_LONGINT($addr)
WEB GET OPTION(Web IP address to listen;$addr)

​$addr = 0

If I set a value WGO returns that value - not the actual IP the web server
is on. ​

​This is v15.3, Mac, BTW. ​

--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

KirkBrooks
In reply to this post by Keisuke Miyako
Miyako,
​I must be missing something here.

On Sun, Jan 15, 2017 at 4:54 PM, Keisuke Miyako <[hidden email]>
wrote:

> it is now recommended to use
>
> WEB GET OPTION
> http://doc.4d.com/4Dv16/4D/16/WEB-GET-OPTION.301-3036901.en.html

I plugged the IP into an on-line IP converter which gives me

192.168.1.3 => 3232235779 or 0xC0A80103


​But this is bigger than MAXLONG = 2147483647 => 127.255.255.255

​​So I don't see how I can even encode an IP where the first quad is
greater than 127.

--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

Jeffrey Kain
MAXLONG is for a signed 4D longint -- so your IP which is greater than MAXLONG would be expressed as a negative number (4D doesn't have an unsigned longint in its language).

--
Jeffrey Kain
[hidden email]


> On Jan 16, 2017, at 1:18 AM, Kirk Brooks <[hidden email]> wrote:
>
> Miyako,
> ​I must be missing something here.
>
> On Sun, Jan 15, 2017 at 4:54 PM, Keisuke Miyako <[hidden email]>
> wrote:
>
>> it is now recommended to use
>>
>> WEB GET OPTION
>> http://doc.4d.com/4Dv16/4D/16/WEB-GET-OPTION.301-3036901.en.html
>
> I plugged the IP into an on-line IP converter which gives me
>
> 192.168.1.3 => 3232235779 or 0xC0A80103
>
>
> ​But this is bigger than MAXLONG = 2147483647 => 127.255.255.255

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: How to get the IP address of the 4D web server within 4D?

KirkBrooks
Jeff,
Thanks. Yeah, this morning when I try all the same code that was giving me
fits yesterday it all just works. Hate that.

I just ran this test method:

C_LONGINT($addrIN;$addrOUT;$a;$b;$c;$d)
$addrIN:=(192 << 24) | (168 << 16) | (1 << 8) | 3
WEB SET OPTION(Web IP address to listen;$addrIN)
// $addrIN = -1062731517

WEB GET OPTION(Web IP address to listen;$addrOUT)
$a:=($addrOUT >> 24)
$b:=($addrOUT >> 16) & 0x00FF
$c:=($addrOUT >> 8) & 0x00FF
$d:=$addrOUT & 0x00FF

$text:=String($addrOUT;"&x")


and everything came out as expected. I should have just re-started
everything when things began to look wonky.

On Mon, Jan 16, 2017 at 7:18 AM, Jeffrey Kain <[hidden email]>
wrote:

> MAXLONG is for a signed 4D longint -- so your IP which is greater than
> MAXLONG would be expressed as a negative number (4D doesn't have an
> unsigned longint in its language).
>

--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************