We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I want to send data from one to another device by using the oscp5 library. Is there a function that returns the IP address of my device in the network? For example: The address of my notebook is 192.168.178.25.
Thank you for your help!
Answers
I'd start by googling "Java get ip address" for a ton of results.
I've already done that but I don't know how to realize it in Processing.
Processing is built on top of Java. Anything you can do in Java, you can do in Processing.
All the results don't work. Maybe you have a link to an example that does work? I am a beginner in programming netzwork communication.
What have you tried? What exactly isn't working for you?
https://stackoverflow.com/questions/9481865/getting-the-ip-address-of-the-current-machine-using-java
Cool, and what happened when you tried that?
I could not even run the programm because there are error messages like "Error on "VariableDeclarators"" or "The class "inetAddress" does not exist".
Sounds like you're missing import statements.
In this example there weren't any lines to import something. Could you please try one of these examples in order to check if it really works? Or do you even have a sketch that already works?
Check these:
https://processing.org/reference/libraries/net/Server_ip_.html
https://forum.processing.org/one/topic/get-the-ip-address-of-the-host-computer.html
You can stick to oscP5 but use this code to retrieve the ip of your machine.
Kf
Thank you. Now it tells me the IP address of the Server (192.168.137.1). But I need to know the address of my device which is 192.168.178.25. How do I get this done?
Ok, your question is how to get the ip address of the device that you want to connect to? The idea is that the server listens, and the client connects to this server. The client needs to know what server to connect to aka. its IP address. You should provide more details of what you are trying to do because working with scarce details leads to an inefficient use of this forum....
Kf
I think you misunderstood me. I want to have a server with a permanent IP-address (settings in my router). Now I will connect clients to it which don't have a permanent IP-address (So the server doesn't know where to send data). Because of that problem every client has to send his IP-address (in my home network) to the server while starting. That's why I need to know how to get the address. I hope I am on the right way of solving my problem.
https://Forum.Processing.org/two/discussions/tagged/port-forwarding
Can't you answer my question yourself instead of just posting a link? Apart from that these questions do not have to do anything with my problem because I want to run server and client in the same network - not over the internet. I just wanted to know how to get the IP of my device. Isn't there anybody who can post a little example code?
https://Docs.Oracle.com/javase/8/docs/api/java/net/InetAddress.html