title: Java Server on multiple network interfaces
body: <p>I wrote a Java <strong>server</strong> application that listens to data coming from the clients and then writes to a database.
  I run the application on a <strong>linux Ubuntu 12.04</strong> computer with two network cards. While I was connecting to the network with a single network interface enabled it works absolutely fine, but when I enable both network interfaces I can receive data only from clients connecting to eth0.</p>
  
  <p>The code of my server is almost classical:</p>
  
  <pre><code>    String address = "0.0.0.0";
      serverSocket = new ServerSocket();
      serverSocket.bind(new InetSocketAddress(address,port));
  
      while (true) {
              Socket clientSocket = null;
              try {
                  clientSocket = serverSocket.accept();
                  System.out.println("\n----Connection accepted----");
                  ConnectionHandler handler = new ConnectionHandler(clientSocket, mysql);
                  Thread handlerThread = new Thread(handler);
                  handlerThread.setPriority(Thread.NORM_PRIORITY);
                  handlerThread.start();
             catch(Exception exc){
                  //catch statement
             }
       }
  </code></pre>
  
  <p>The problem is something weird because <strong>the address "0.0.0.0" should create a socket listening on all the interfaces</strong>.</p>
  
  <p>Something can suggest me how to solve the problem?</p>
  
  <p>EDIT:
  Probably the problem is in the SO settings.</p>
  
  <p>This is the content of my /etc/network/interfaces file:</p>
  
  <pre><code>auto lo
  iface lo inet loopback
  </code></pre>
  
  <p>This is the result of the <em>sudo lshw -class network</em> command</p>
  
  <pre><code>~$ sudo lshw -class network
  [sudo] password for administrator: 
    *-network               
         description: Ethernet interface
         product: I210 Gigabit Network Connection
         vendor: Intel Corporation
         physical id: 0
         bus info: pci@0000:02:00.0
         logical name: eth0
         version: 03
         serial: 90:1b:0e:0b:11:22
         size: 100Mbit/s
         capacity: 1Gbit/s
         width: 32 bits
         clock: 33MHz
         capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
         configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.0.5-k duplex=full firmware=3.16, 0x800005ae ip=10.0.0.100 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s
         resources: irq:18 memory:f7a00000-f7a7ffff ioport:e000(size=32) memory:f7a80000-f7a83fff
    *-network
         description: Ethernet interface
         product: I210 Gigabit Network Connection
         vendor: Intel Corporation
         physical id: 0
         bus info: pci@0000:03:00.0
         logical name: eth1
         version: 03
         serial: 90:1b:0e:0b:0f:25
         size: 100Mbit/s
         capacity: 1Gbit/s
         width: 32 bits
         clock: 33MHz
         capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
         configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.0.5-k duplex=full firmware=3.16, 0x800005b0 ip=192.168.150.100 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s
         resources: irq:19 memory:f7900000-f797ffff ioport:d000(size=32) memory:f7980000-f7983fff
  </code></pre>