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 & HelpPrograms › Getting the IP address of a program
Page Index Toggle Pages: 1
Getting the IP address of a program (Read 732 times)
Getting the IP address of a program
Feb 25th, 2006, 10:35pm
 
Hi,
I'm trying to get the IP address of a processing program, and I can't seem to find any way except loading a string from a site like my own www.staronesw.com/webcam/ip.php

Is there any easy way to get the IP address of a the local machine? (not 127.0.0.1 either)
Re: Getting the IP address of a program
Reply #1 - Feb 26th, 2006, 5:27pm
 
I don't know if this is a 'proper' way to do it (I don't know java), but it seems to work (for my desktop anyway)...

import java.net.InetAddress;
InetAddress inet;
try {
 inet = InetAddress.getLocalHost();
 println(inet);
}
catch (Exception e) {
 e.printStackTrace();
}

edit: probably worth noting that (if I understand this right) in the above example, 'inet' is of type InetAddress, not a string. So you'll have to convert it to a string (and extract the IP part) to use it with processing.net's Client objects.

Found it here:

http://java.sun.com/j2se/1.3/docs/api/java/net/InetAddress.html
Page Index Toggle Pages: 1