# How to specify the IP when multi networkcard

**URL:** https://discourse.processing.org/t/how-to-specify-the-ip-when-multi-networkcard/44438
**Category:** Libraries
**Created:** [May 16, 2024, 2:28pm UTC](https://discourse.processing.org/t/how-to-specify-the-ip-when-multi-networkcard/44438 "2024-05-16T14:28:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![techno](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@techno](https://discourse.processing.org/u/techno)
#### Post date: [May 16, 2024, 2:28pm UTC](https://discourse.processing.org/t/how-to-specify-the-ip-when-multi-networkcard/44438/1 "2024-05-16T14:28:49Z")

</div>

i’m teacher and use processing in teaching  
i ve 2 networks cards in the computer of the student. so i have 2 ipadresse. (ethernet and wlan)  
how to specify the second adresse ip in : s = new Server(this, 8080);  
i can’t set for exemple s = new Server(this, 8080,“192.168.1.12”);  
because it will only works on one computer. I want it will work on any computer of my classroom  
i have to set in s = new Server(this, 8080); the second ip adresse for the app works  
thanks a lot  
ps : sorry for the writting, i’m french

---

<div class="post-metadata">

### Author: ![techno](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@techno](https://discourse.processing.org/u/techno)
#### Post date: [May 16, 2024, 4:13pm UTC](https://discourse.processing.org/t/how-to-specify-the-ip-when-multi-networkcard/44438/2 "2024-05-16T16:13:09Z")

</div>

thanks to chatgpt i have a solution to implement.

```auto
import java.net.*;
import java.util.*;

void setup() {
  size(400, 200);
  try {
    Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
    while (interfaces.hasMoreElements()) {
      NetworkInterface iface = interfaces.nextElement();
      if (!iface.isLoopback() && iface.isUp()) {
        Enumeration<InetAddress> addresses = iface.getInetAddresses();
        while (addresses.hasMoreElements()) {
          InetAddress addr = addresses.nextElement();
          println("Interface: " + iface.getName() + ", IP: " + addr.getHostAddress());
        }
      }
    }
  } 
  catch (SocketException e) {
    e.printStackTrace();
  }
}

```

with addr.getHostAddress(), i have the IP of the computer

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [June 19, 2024, 12:52am UTC](https://discourse.processing.org/t/how-to-specify-the-ip-when-multi-networkcard/44438/3 "2024-06-19T00:52:34Z")

</div>

Hello @techno,

I took interest but could not run the code you provided because it was not properly formatted.

See:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

I cut and past your code into ChatGPT and it corrected it.

Here is the code correctly formatted for posting:

```auto
void setup() {
    size(400, 200);
    try {
        Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
        while (interfaces.hasMoreElements()) {
            NetworkInterface iface = interfaces.nextElement();
            if (!iface.isLoopback() && iface.isUp()) {
                Enumeration<InetAddress> addresses = iface.getInetAddresses();
                while (addresses.hasMoreElements()) {
                    InetAddress addr = addresses.nextElement();
                    println("Interface: " + iface.getName() + ", IP: " + addr.getHostAddress());
                }
            }
        }
    } catch (SocketException e) {
        e.printStackTrace();
    }
}

```

`:)`
