Getting server IP address

Bastiaan Olij lists at basenlily.nl
Wed Apr 15 00:33:54 EDT 2009


Hey Joe,

I'm very aware of the multiple interface issue, when binding a port
though, you can bind it on all interfaces meaning any traffic that comes
in on that port automatically goes to your app (in code, simply listen
on IP 0.0.0.0 if I recall correctly from doing (win)sock programming in
C a long long time ago) . Omnis most likely works like this.
That said, only one, maybe two interfaces will be relevant to my cause.
Just getting a list of possible ones will help me a long way along though.

As for changing the bound port. This often is a problem with apps
reading a text based configuration file at startup. Changing the
configuration file won't have effect until the app is restarted. Omnis
on the other hand knows fully well when you change $serverport. It was
originally so that the binding was still being done on startup but as of
4.3 changing $serverport to a value will bind right away if the server
port was previously unbound. It just doesn't seem to change the binding
on the fly. I was hoping there was a trick to this because unbinding a
port and binding to another port is tcp-ip 101.

Greetz,

Bas

Joe Maus wrote:
> ----- Bastiaan Olij <lists at basenlily.nl> wrote:
>   
>> Hey $All,
>>
>> I'm sure this was handled a week or so ago but I can't find the topic
>> anymore on the list. I want to know what the IP addresses are on which
>> Omnis is listening (or just get these from the OS and assume Omnis is
>> listening through those IPs). I need a solution for both Mac and Windows
>>     
>
> Trouble here is there can be multiple interfaces running or "present" - often virtual interfaces for VPN connections and other processes are present in that list causing one to wonder what, exactly, is the correct IP to use...  Then, of course, there is DHCP and sometimes the IP can be changed and Omnis is just listening to static (although this is rare for servers) once that happens.  And then there are servers that have say 4 interfaces on them - some may be valid to listen on, others not - so how to tell from an interrogation of the OS?  Answer is you really can't.  You have to know where you'll be listening before you start it up.  And I'm pretty sure (although not 100%) Omnis will only listen on one IP at a time (as it can bind only one port for webserver, this seems to make sense logically, at least to me).  Perhaps TCPGetMyAddress will return the address Omnis is using all of the time?  (As opposed to returning just one of the IPs available to it from the network listing where that IP may not be the one it is actually bound to.)
>
>   
>> Also does someone know how I can force Omnis to accept another port?
>> I've noticed that when $serverport is not set and I set it, Omnis binds
>> to that port right away, but if I change $serverport afterwards I need
>> to restart Omnis before it will bind to the new port meaning $serverport
>> and the actual port Omnis is listening on could be different.
>>     
>
> Every program that I've come across requires a restart if you change the bound port.  I do not pretend to know if this is always true, just that everything I've come across requires a restart in this case.  At least in the PC world.  And yes, you need to start Omnis, enter the value, and then restart Omnis to get it to bind.  It will only bind with the port specified in $serverport - it will not bind to any other random port.  It that port is not available, it should throw an error that that port is already in use.  Use "netstat" from the command line to see the ports in use already ("netstat ?" to see all of the available parameters).
>
> Fun with networking!  How I enjoy it...
>
> Regards,
>
> Joe Maus
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
>
>   





More information about the omnisdev-en mailing list