Merge pull request #223 from jbonofre/KARAF-6987

[KARAF-6987] Add host property on socket collector allowing to define the binding address/host
diff --git a/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg b/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg
index fdc3f12..81b5597 100644
--- a/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg
+++ b/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg
@@ -22,6 +22,9 @@
 # Port number on which to listen
 #port=34343
 
+# Binding address on which to listen
+#host=0.0.0.0
+
 # Number of worker threads to deal with
 #workers=10
 
diff --git a/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java b/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java
index 163d49e..996dfa5 100644
--- a/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java
+++ b/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java
@@ -17,10 +17,7 @@
 package org.apache.karaf.decanter.collector.socket;
 
 import java.io.*;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.ServerSocket;
-import java.net.Socket;
+import java.net.*;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Map;
@@ -79,6 +76,7 @@
     public void activate(Dictionary<String, Object> properties) throws IOException {
         this.properties = properties;
         int port = Integer.parseInt(getProperty(this.properties, "port", "34343"));
+        String host = getProperty(this.properties, "host", "0.0.0.0");
         int workers = Integer.parseInt(getProperty(this.properties, "workers", "10"));
 
         this.protocol = Protocol.valueOf(getProperty(this.properties, "protocol", "tcp").toUpperCase());
@@ -91,10 +89,10 @@
 
         switch (protocol) {
             case TCP:
-                this.serverSocket = new ServerSocket(port);
+                this.serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host));
                 break;
             case UDP:
-                this.datagramSocket = new DatagramSocket(port);
+                this.datagramSocket = new DatagramSocket(port, InetAddress.getByName(host));
                 break;
         }
 
diff --git a/manual/src/main/asciidoc/user-guide/collectors.adoc b/manual/src/main/asciidoc/user-guide/collectors.adoc
index 02a60f0..10d9831 100644
--- a/manual/src/main/asciidoc/user-guide/collectors.adoc
+++ b/manual/src/main/asciidoc/user-guide/collectors.adoc
@@ -669,6 +669,9 @@
 # Port number on which to listen
 #port=34343
 
+# Binding address on which to listen
+#host=0.0.0.0
+
 # Number of worker threads to deal with
 #workers=10
 
@@ -681,6 +684,7 @@
 ----
 
 * the `port` property contains the port number where the network socket collector is listening
+* the `host` property contains the host name/interface address where the network socket collector is listening
 * the `workers` property contains the number of worker threads the socket collector is using for the connection
 * the `protocol` property contains the protocol used by the collector for transferring data with the client
 * the `unmarshaller.target` property contains the unmarshaller used by the collector to transform the data