The way how to retrieve local IP?
I know there was post about it but solution I posted there isnt suitable for all situations.
Also Im working on some program for snake-keepers. There is also direct CHAT part (MooSock)
Those people usually dont know how to retrieve their IP and thats the problem. If there is "ENTER IP TO CONNECT" they all wont know where to find it out. The person who would host cant see his IP <img src="/center/images/graemlins/frown.gif" alt="" />
Is there any way which could lead to simple text: Your IP is... ? I tried hosting and retrieving IP, connecting to localhost (retrieves 127.0.0.1 of course :/) without success... Any advice is welcome, thank you
Re: The way how to retrieve local IP?
The only way is to connect to another computer and then ask moosock what your ip is. This is because a pc can have more than one IP, so it does this to find out which IP the connection you need is on. Of course if the chat is over the internet and the host is behind router / NAT it won't work unless they forward the port on their router themself. So, better to both connect to another dedicated server on the internet for internet chat.
Another tip is you can use a pc's name instead of an IP if you're on lan, just like how you can use a server address like www.google.com on the internet.
Re: The way how to retrieve local IP?
Yes, I was affraid about this <img src="/center/images/graemlins/frown.gif" alt="" /> Thank you anyway
Re: The way how to retrieve local IP?
You could use a PHP script, host it on a webserver and then retrieve it using MooSock. Downsides to this are that if your site goes down then you can't retrieve the IP, but it's the best way I've found to do it.
Open notepad, and type in
<? $ip=@$REMOTE_ADDR; echo("[del]$ip[del]"); ?>
Save the file as ip.php and then upload it to your webserver (e.g. www.myserver.com/ip.php)
In MMF2, use similar to the following:
+ Start of frame
- String parser: Add delimeter "[del]"
- Connect to www.myserver.com on port 80
+ On connect
- Send text line "GET /ip.php HTTP/1.1"
- Send text line "Host: www.myserver.com"
- Send text line ""
+ On received
- String parser: Set source string to Recv$( "MooSock", 1024)
+ On disconnect
- Edit box: Set text to listGetAt$( "String Parser", 2)
If you find that your webserver doesn't disconnect after receieving the text, then try changing the HTTP/1.1 to HTTP/1.0. I recently bought new webspace, and it seems that it'll only disconnect when I use HTTP/1.0 for some reason..
Re: The way how to retrieve local IP?
Yes, I absolutely forgot about that! Thank you Flava, its the best way I think too.