We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › oscP5 get local IP question
Page Index Toggle Pages: 1
oscP5 get local IP question (Read 366 times)
oscP5 get local IP question
Feb 27th, 2009, 10:06am
 
Hi
I want to communicate with a other program on the same computer.
In this condition,  Processing and the other program have the same IP  adress.

My ip adress is for example "10.0.1.2"
so for this I do:

oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("10.0.1.2",12000);

but if my ip change , I have to edit my code to write the new ip adress

I try to find a way to get my ip adress automatically so it will works without editing my code.
something like:

oscP5 = new OscP5(this,12000);
myIP= getLocalIP();  ???????
myRemoteLocation = new NetAddress(myIP,12000);


Any ideas

thanks

Re: oscP5 get local IP question
Reply #1 - Feb 27th, 2009, 10:21am
 
are you trying to send messages to your own/local machine? then use 127.0.0.1 as ip address. 127.0.0.1 refers to your local machine. if this is not what you are looking for, you can also use NetInfo to determine your local are network (LAN) address and your wide are network (WAN) address. use:
Code:

String myLAN = NetInfo.lan();
String myWAN = NetInfo.wan();
println(myLAN+" / "+myWAN);

best,
andreas
Page Index Toggle Pages: 1