Index: trunk/lib/FlairCore/src/Socket.cpp
===================================================================
--- trunk/lib/FlairCore/src/Socket.cpp	(revision 177)
+++ 	(revision )
@@ -1,91 +1,0 @@
-// %flair:license{
-// This file is part of the Flair framework distributed under the
-// CECILL-C License, Version 1.0.
-// %flair:license}
-//  created:    2013/11/17
-//  filename:   Socket.cpp
-//
-//  author:     Guillaume Sanahuja
-//              Copyright Heudiasyc UMR UTC/CNRS 7253
-//
-//  version:    $Id: $
-//
-//  purpose:    Class defining a UDP socket
-//
-//
-/*********************************************************************/
-#include "Socket.h"
-#include "Socket_impl.h"
-#include <FrameworkManager.h>
-#include <string.h>
-#include <stdexcept>
-
-using std::string;
-
-namespace flair {
-namespace core {
-
-Socket::Socket(const Object *parent, string name, uint16_t port)
-    : Object(parent, name) {
-  pimpl_ = new Socket_impl(this, name, port);
-}
-
-Socket::Socket(const Object *parent, string name, string address,
-               bool broadcast)
-    : Object(parent, name) {
-  pimpl_ = new Socket_impl(this, name, address, broadcast);
-}
-
-Socket::~Socket() { delete pimpl_; }
-
-void Socket::SendMessage(const char *message, size_t message_len) {
-  pimpl_->SendMessage(message, message_len);
-}
-
-void Socket::SendMessage(string message) { pimpl_->SendMessage(message); }
-
-ssize_t Socket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,
-                            size_t *src_len) {
-  return pimpl_->RecvMessage(buf, buf_len, timeout, src, src_len);
-}
-
-void Socket::NetworkToHost(char *data, size_t dataSize) {
-  if (core::IsBigEndian())
-    return;
-  if (dataSize == 1)
-    return;
-  if ((dataSize == 2) || (dataSize == 4) || (dataSize == 8) ||
-      (dataSize == 16)) {
-    char dataInHostEndianness[dataSize];
-    for (unsigned int i = 0; i < dataSize; i++) {
-      dataInHostEndianness[i] = data[dataSize - i - 1];
-    }
-    memcpy(data, dataInHostEndianness, dataSize);
-    return;
-  }
-  throw std::runtime_error(
-      string("Unsupported data size (") + std::to_string(dataSize) +
-      string(") in host to network endianness conversion"));
-}
-
-void Socket::HostToNetwork(char *data, size_t dataSize) {
-  if (IsBigEndian())
-    return;
-  if (dataSize == 1)
-    return;
-  if ((dataSize == 2) || (dataSize == 4) || (dataSize == 8) ||
-      (dataSize == 16)) {
-    char dataInNetworkEndianness[dataSize];
-    for (unsigned int i = 0; i < dataSize; i++) {
-      dataInNetworkEndianness[i] = data[dataSize - i - 1];
-    }
-    memcpy(data, dataInNetworkEndianness, dataSize);
-    return;
-  }
-  throw std::runtime_error(
-      string("Unsupported data size (") + std::to_string(dataSize) +
-      string(") in host to network endianness conversion"));
-}
-
-} // end namespace core
-} // end namespace flair
Index: trunk/lib/FlairCore/src/Socket.h
===================================================================
--- trunk/lib/FlairCore/src/Socket.h	(revision 177)
+++ 	(revision )
@@ -1,111 +1,0 @@
-// %flair:license{
-// This file is part of the Flair framework distributed under the
-// CECILL-C License, Version 1.0.
-// %flair:license}
-/*!
- * \file Socket.h
- * \brief Class defining a UDP socket
- * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
- * \date 2013/11/17
- * \version 4.0
- */
-
-#ifndef SOCKET_H
-#define SOCKET_H
-
-#include <unistd.h>
-#include <stdint.h>
-#include <Object.h>
-
-class Socket_impl;
-
-namespace flair {
-namespace core {
-
-/*! \class Socket
-*
-* \brief Class encapsulating a UDP socket. It assumes packets are coming from
-*only one distant host on a given port.
-*
-*/
-class Socket : public Object {
-public:
-  /*!
-  * \brief Constructor
-  *
-  * Construct the client side of the socket
-  *
-  * \param parent parent
-  * \param name name
-  * \param address server address (ex 192.168.1.1:9000)
-  * \param broadcast true if address is a broadcast address
-  */
-  Socket(const Object *parent, std::string name, std::string address,
-         bool broadcast = false);
-
-  /*!
-  * \brief Constructor
-  *
-  * Construct the server side of the socket
-  *
-  * \param parent parent
-  * \param name name
-  * \param port listening port
-  */
-  Socket(const Object *parent, std::string name, uint16_t port);
-
-  /*!
-  * \brief Destructor
-  *
-  */
-  ~Socket();
-
-  /*!
-  * \brief Send a message
-  *
-  * In case of a broadcast Socket, Parent()->ObjectName() is used as source of
-  *the message, this name should be unique.
-  *
-  * \param message message
-  */
-  void SendMessage(std::string message);
-
-  /*!
-  * \brief Send a message
-  *
-  * \param message message
-  * \param message_len message length
-  */
-  void SendMessage(const char *message, size_t message_len);
-
-  /*!
-  * \brief Receive a message
-  *
-  * Receive a message and wait up to timeout. \n
-  * If src and src_len are specified, the source of the message will be
-  * copied in the src buffer. \n
-  * Note that in case of a broadcast socket, own messages are filtered and
-  * are not received.
-  *
-  * \param buf buffer to put the message
-  * \param buf_len buffer length
-  * \param timeout timeout
-  * \param src buffer to put source name
-  * \param src_len buffer length
-  *
-  * \return size of the received message
-  */
-  ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout, char *src = NULL,
-                      size_t *src_len = NULL);
-
-  void NetworkToHost(char *data, size_t dataSize);
-  void HostToNetwork(char *data, size_t dataSize);
-
-private:
-  class Socket_impl *pimpl_;
-};
-
-} // end namespace core
-} // end namespace flair
-
-#endif // SOCKET_H
Index: trunk/lib/FlairCore/src/Socket_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/Socket_impl.cpp	(revision 177)
+++ 	(revision )
@@ -1,375 +1,0 @@
-// %flair:license{
-// This file is part of the Flair framework distributed under the
-// CECILL-C License, Version 1.0.
-// %flair:license}
-//  created:    2013/11/17
-//  filename:   Socket_impl.cpp
-//
-//  author:     Guillaume Sanahuja
-//              Copyright Heudiasyc UMR UTC/CNRS 7253
-//
-//  version:    $Id: $
-//
-//  purpose:    classe pour une Socket_impl
-//
-//
-/*********************************************************************/
-#include "Socket_impl.h"
-#include "Socket.h"
-#include "FrameworkManager.h"
-#include <fcntl.h>
-#include <cstdlib>
-#include <unistd.h>
-#include <string.h>
-#ifdef __XENO__
-#include "config.h"
-#endif
-
-using std::string;
-using namespace flair::core;
-
-Socket_impl::Socket_impl(const Socket *self, string name, uint16_t port) {
-  this->self = self;
-  this->port = port;
-  this->address = "";
-  this->broadcast = false;
-  Init();
-}
-
-Socket_impl::Socket_impl(const Socket *self, string name, string address,
-                         bool broadcast) {
-  this->self = self;
-  int pos = address.find(":");
-  this->address = address.substr(0, pos);
-  port = atoi(address.substr(pos + 1).c_str());
-  this->broadcast = broadcast;
-
-  if (pos == 0 || address == "") {
-    self->Err("address %s is not correct\n", address.c_str());
-  }
-  Init();
-}
-
-void Socket_impl::Init(void) {
-  int yes = 1;
-
-  fd = socket(AF_INET, SOCK_DGRAM, 0); // UDP
-
-  if (broadcast == true) {
-    if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(int)) != 0)
-      self->Err("Setsockopt error\n");
-  }
-
-  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0)
-    self->Err("Setsockopt error\n");
-
-  if (address == "" || broadcast == true) {
-    sockaddr_in sin = {0};
-
-    if (broadcast == true) {
-      struct hostent *hostinfo;
-
-      hostinfo = gethostbyname(this->address.c_str());
-      if (hostinfo == NULL) {
-        self->Err("hostinfo error\n");
-      }
-      sin.sin_addr = *(in_addr *)hostinfo->h_addr;
-    } else {
-      sin.sin_addr.s_addr = INADDR_ANY;
-    }
-
-    sin.sin_port = htons(port);
-    sin.sin_family = AF_INET;
-    if (bind(fd, (sockaddr *)&sin, sizeof sin) == -1) {
-      self->Err("bind error\n");
-    }
-  }
-
-#ifdef __XENO__
-  string tmp_name;
-  int status;
-  is_running = true;
-
-  // pipe
-  tmp_name =
-      getFrameworkManager()->ObjectName() + "-" + self->ObjectName() + "-pipe";
-  // xenomai limitation
-  if (tmp_name.size() > 31)
-    self->Err("rt_pipe_create error (%s is too long)\n", tmp_name.c_str());
-#ifdef RT_PIPE_SIZE
-  status = rt_pipe_create(&pipe, tmp_name.c_str(), P_MINOR_AUTO, RT_PIPE_SIZE);
-#else
-  status = rt_pipe_create(&pipe, tmp_name.c_str(), P_MINOR_AUTO, 0);
-#endif
-  if (status != 0) {
-		char errorMsg[256];
-    self->Err("rt_pipe_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
-  }
-
-// start user side thread
-#ifdef NRT_STACK_SIZE
-  // Initialize thread creation attributes
-  pthread_attr_t attr;
-  if (pthread_attr_init(&attr) != 0) {
-    self->Err("pthread_attr_init error\n");
-  }
-  if (pthread_attr_setstacksize(&attr, NRT_STACK_SIZE) != 0) {
-    self->Err("pthread_attr_setstacksize error\n");
-  }
-  if (pthread_create(&user_thread, &attr, user, (void *)this) < 0) {
-    self->Err("pthread_create error\n");
-  }
-  if (pthread_attr_destroy(&attr) != 0) {
-    self->Err("pthread_attr_destroy error\n");
-  }
-#else  // NRT_STACK_SIZE
-  if (pthread_create(&user_thread, NULL, user, (void *)this) < 0) {
-    self->Err("pthread_create error\n");
-  }
-#endif // NRT_STACK_SIZE
-#endif //__XENO__
-
-  if (address != "") {
-    struct hostent *hostinfo;
-    hostinfo = gethostbyname(address.c_str());
-    if (hostinfo == NULL) {
-      self->Err("gethostbyname\n");
-    }
-
-    sock_in.sin_addr = *(in_addr *)hostinfo->h_addr;
-    sock_in.sin_port = htons(port);
-    sock_in.sin_family = AF_INET;
-  }
-}
-
-Socket_impl::~Socket_impl() {
-#ifdef __XENO__
-  is_running = false;
-
-  pthread_join(user_thread, NULL);
-  int status = rt_pipe_delete(&pipe);
-  if (status != 0) {
-		char errorMsg[256];
-    self->Err("rt_pipe_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
-	}
-#endif
-  close(fd);
-}
-
-void Socket_impl::SendMessage(const char *src, size_t src_len) {
-  ssize_t written;
-  string to_send;
-	char errorMsg[256];
-
-  if (broadcast == true) {
-    to_send = getFrameworkManager()->ObjectName() + ":" + string(src, src_len);
-    src_len = to_send.size();
-    src = (char *)to_send.c_str();
-  }
-
-#ifdef __XENO__
-  // Printf("send pipe %s\n",src);
-  written = rt_pipe_write(&pipe, src, src_len, P_NORMAL);
-
-  if (written < 0) {
-    self->Err("rt_pipe_write error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
-  } else if (written != (ssize_t)src_len) {
-    self->Err("rt_pipe_write error %i/%i\n", written, to_send.size());
-  }
-#else
-  written =
-      sendto(fd, src, src_len, 0, (struct sockaddr *)&sock_in, sizeof(sock_in));
-  if(written==-1) {
-		char errorMsg[256];
-    self->Err("sendto error (%s)\n",strerror_r(errno, errorMsg, sizeof(errorMsg)));
-  } else if (written != (ssize_t)src_len) {
-    self->Err("sendto error %i/%i\n",written,src_len);
-  }
-#endif
-}
-
-void Socket_impl::SendMessage(string message) {
-  ssize_t written;
-
-  if (broadcast == true)
-    message = self->Parent()->ObjectName() + ":" + message;
-// Printf("SendMessage %s\n",message.c_str());
-#ifdef __XENO__
-  written = rt_pipe_write(&pipe, message.c_str(), message.size(), P_NORMAL);
-
-  if (written < 0) {
-		char errorMsg[256];
-    self->Err("rt_pipe_write error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
-  } else if (written != (ssize_t)message.size()) {
-    self->Err("rt_pipe_write error %i/%i\n", written, message.size());
-  }
-#else
-  written = sendto(fd, message.c_str(), message.size(), 0,
-                   (struct sockaddr *)&sock_in, sizeof(sock_in));
-  if (written != (ssize_t)message.size()) {
-    self->Err("sendto error\n");
-  }
-
-#endif
-}
-
-ssize_t Socket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,
-                                 char *src, size_t *src_len) {
-  ssize_t nb_read;
-  char buffer[128];
-#ifdef __XENO__
-  nb_read = rt_pipe_read(&pipe, &buffer, sizeof(buffer), timeout);
-#else
-  socklen_t sinsize = sizeof(sock_in);
-  struct timeval tv;
-
-  if (timeout != TIME_NONBLOCK) {
-    int attr = fcntl(fd, F_GETFL, 0);
-    fcntl(fd, F_SETFL, attr & (~O_NONBLOCK));
-
-    tv.tv_sec = timeout / 1000000000;
-    timeout = timeout - (timeout / 1000000000) * 1000000000;
-    tv.tv_usec = timeout / 1000;
-    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
-      self->Err("setsockopt SO_RCVTIMEO failed\n");
-    }
-  } else {
-    fcntl(fd, F_SETFL, O_NONBLOCK);
-  }
-
-  if (broadcast == false) {
-    nb_read =
-        recvfrom(fd, buffer, sizeof(buffer), 0, (sockaddr *)&sock_in, &sinsize);
-  } else {
-    nb_read = recvfrom(fd, buffer, sizeof(buffer), 0, NULL, NULL);
-  }
-#endif
-  if (nb_read <= 0) {
-    return nb_read;
-  } else {
-    // printf("%s\n",buffer);
-    if (broadcast == true) {
-      int index = -1;
-      for (int i = 0; i < nb_read; i++) {
-        if (buffer[i] == ':') {
-          index = i;
-          break;
-        }
-      }
-      if (index < 0) {
-        self->Warn("Malformed message\n");
-        return -1;
-      } else if (src_len != NULL && src != NULL) {
-        if (index + 1 > (int)(*src_len) &&
-            src != NULL) { //+1 pour inserer un 0)
-          self->Warn("insufficent src size\n");
-          return -1;
-        }
-      } else if (nb_read - index - 1 + 1 >
-                 (int)msg_len) { //+1 pour inserer un 0
-        self->Warn("insufficent msg size (%i/%i)\n", nb_read - index - 1 + 1,
-                   msg_len);
-        return -1;
-      }
-      if (src != NULL) {
-        memcpy(src, buffer, index);
-        src[index] = 0;
-      }
-      memcpy(msg, &buffer[index + 1], nb_read - index - 1);
-      msg[nb_read - index - 1] = 0;
-      return nb_read - index;
-    } else {
-      if (nb_read > (int)msg_len) {
-        self->Warn("insufficent msg size (%i/%i)\n", nb_read, msg_len);
-        return -1;
-      }
-      memcpy(msg, buffer, nb_read);
-      return nb_read;
-    }
-  }
-}
-
-#ifdef __XENO__
-void *Socket_impl::user(void *arg) {
-  Socket_impl *caller = (Socket_impl *)arg;
-  int pipe_fd = -1;
-  string devname;
-
-  devname = NRT_PIPE_PATH + getFrameworkManager()->ObjectName() + "-" +
-            caller->self->ObjectName() + "-pipe";
-  while (pipe_fd < 0) {
-    pipe_fd = open(devname.c_str(), O_RDWR);
-    if (pipe_fd < 0 && errno != ENOENT) {
-			char errorMsg[256];
-			caller->self->Err("open pipe_fd error (%s)\n", strerror_r(errno, errorMsg, sizeof(errorMsg)));
-		}
-    usleep(1000);
-  }
-
-  while (caller->is_running == true) {
-    fd_set set;
-    struct timeval timeout;
-    int rv;
-
-    FD_ZERO(&set);            // clear the set
-    FD_SET(caller->fd, &set); // add our file descriptor to the set
-    FD_SET(pipe_fd, &set);    // add our file descriptor to the set
-
-    timeout.tv_sec = 0;
-    timeout.tv_usec = SELECT_TIMEOUT_MS * 1000;
-    rv = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
-
-    if (rv == -1) {
-      caller->self->Err("select error\n"); // an error occured
-    } else if (rv == 0) {
-      // printf("timeout\n");
-    } else {
-      ssize_t nb_read, nb_write;
-      char buffer[1024];
-
-      if (FD_ISSET(caller->fd, &set)) {
-        socklen_t sinsize = sizeof(caller->sock_in);
-        if (caller->broadcast == false) {
-          nb_read = recvfrom(caller->fd, buffer, sizeof(buffer), 0,
-                             (sockaddr *)&(caller->sock_in), &sinsize);
-        } else {
-          nb_read = recvfrom(caller->fd, buffer, sizeof(buffer), 0, NULL, NULL);
-        }
-        if (nb_read < 0) {
-          caller->self->Err("recvfrom error\n");
-        }
-        // printf("user %s\n",buffer);
-        // on ne garde que les messages venant pas de soi meme
-        if (caller->broadcast == false ||
-            (caller->broadcast == true &&
-             getFrameworkManager()->ObjectName().compare(
-                 0, getFrameworkManager()->ObjectName().size(), buffer,
-                 getFrameworkManager()->ObjectName().size()) != 0)) {
-          nb_write = write(pipe_fd, buffer, nb_read);
-          if (nb_write != nb_read) {
-            caller->self->Err("write error\n");
-          }
-        } else {
-          // printf("self %s\n",buffer);
-        }
-      }
-      if (FD_ISSET(pipe_fd, &set)) {
-        nb_read = read(pipe_fd, buffer, sizeof(buffer));
-        // printf("read pipe %i %s\n",nb_read,buffer);
-        if (nb_read > 0) {
-          // printf("send %s\n",buffer);
-          nb_write = sendto(caller->fd, buffer, nb_read, 0,
-                            (struct sockaddr *)&(caller->sock_in),
-                            sizeof(caller->sock_in));
-          if (nb_write != nb_read) {
-            caller->self->Err("sendto error\n");
-          }
-        }
-      }
-    }
-  }
-
-  close(pipe_fd);
-  pthread_exit(0);
-}
-#endif
Index: trunk/lib/FlairCore/src/UdpSocket.cpp
===================================================================
--- trunk/lib/FlairCore/src/UdpSocket.cpp	(revision 178)
+++ trunk/lib/FlairCore/src/UdpSocket.cpp	(revision 178)
@@ -0,0 +1,91 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2013/11/17
+//  filename:   UdpSocket.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    Class defining a UDP socket
+//
+//
+/*********************************************************************/
+#include "UdpSocket.h"
+#include "UdpSocket_impl.h"
+#include <FrameworkManager.h>
+#include <string.h>
+#include <stdexcept>
+
+using std::string;
+
+namespace flair {
+namespace core {
+
+UdpSocket::UdpSocket(const Object *parent, string name, uint16_t port)
+    : Object(parent, name) {
+  pimpl_ = new UdpSocket_impl(this, name, port);
+}
+
+UdpSocket::UdpSocket(const Object *parent, string name, string address,
+               bool broadcast)
+    : Object(parent, name) {
+  pimpl_ = new UdpSocket_impl(this, name, address, broadcast);
+}
+
+UdpSocket::~UdpSocket() { delete pimpl_; }
+
+void UdpSocket::SendMessage(const char *message, size_t message_len) {
+  pimpl_->SendMessage(message, message_len);
+}
+
+void UdpSocket::SendMessage(string message) { pimpl_->SendMessage(message); }
+
+ssize_t UdpSocket::RecvMessage(char *buf, size_t buf_len, Time timeout, char *src,
+                            size_t *src_len) {
+  return pimpl_->RecvMessage(buf, buf_len, timeout, src, src_len);
+}
+
+void UdpSocket::NetworkToHost(char *data, size_t dataSize) {
+  if (core::IsBigEndian())
+    return;
+  if (dataSize == 1)
+    return;
+  if ((dataSize == 2) || (dataSize == 4) || (dataSize == 8) ||
+      (dataSize == 16)) {
+    char dataInHostEndianness[dataSize];
+    for (unsigned int i = 0; i < dataSize; i++) {
+      dataInHostEndianness[i] = data[dataSize - i - 1];
+    }
+    memcpy(data, dataInHostEndianness, dataSize);
+    return;
+  }
+  throw std::runtime_error(
+      string("Unsupported data size (") + std::to_string(dataSize) +
+      string(") in host to network endianness conversion"));
+}
+
+void UdpSocket::HostToNetwork(char *data, size_t dataSize) {
+  if (IsBigEndian())
+    return;
+  if (dataSize == 1)
+    return;
+  if ((dataSize == 2) || (dataSize == 4) || (dataSize == 8) ||
+      (dataSize == 16)) {
+    char dataInNetworkEndianness[dataSize];
+    for (unsigned int i = 0; i < dataSize; i++) {
+      dataInNetworkEndianness[i] = data[dataSize - i - 1];
+    }
+    memcpy(data, dataInNetworkEndianness, dataSize);
+    return;
+  }
+  throw std::runtime_error(
+      string("Unsupported data size (") + std::to_string(dataSize) +
+      string(") in host to network endianness conversion"));
+}
+
+} // end namespace core
+} // end namespace flair
Index: trunk/lib/FlairCore/src/UdpSocket.h
===================================================================
--- trunk/lib/FlairCore/src/UdpSocket.h	(revision 178)
+++ trunk/lib/FlairCore/src/UdpSocket.h	(revision 178)
@@ -0,0 +1,111 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file Socket.h
+ * \brief Class defining a UDP socket
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2013/11/17
+ * \version 4.0
+ */
+
+#ifndef UDPSOCKET_H
+#define UDPSOCKET_H
+
+#include <unistd.h>
+#include <stdint.h>
+#include <Object.h>
+
+class UdpSocket_impl;
+
+namespace flair {
+namespace core {
+
+/*! \class UdpSocket
+*
+* \brief Class encapsulating a UDP socket. It assumes packets are coming from
+*only one distant host on a given port.
+*
+*/
+class UdpSocket : public Object {
+public:
+  /*!
+  * \brief Constructor
+  *
+  * Construct the client side of the socket
+  *
+  * \param parent parent
+  * \param name name
+  * \param address server address (ex 192.168.1.1:9000)
+  * \param broadcast true if address is a broadcast address
+  */
+  UdpSocket(const Object *parent, std::string name, std::string address,
+         bool broadcast = false);
+
+  /*!
+  * \brief Constructor
+  *
+  * Construct the server side of the socket
+  *
+  * \param parent parent
+  * \param name name
+  * \param port listening port
+  */
+  UdpSocket(const Object *parent, std::string name, uint16_t port);
+
+  /*!
+  * \brief Destructor
+  *
+  */
+  ~UdpSocket();
+
+  /*!
+  * \brief Send a message
+  *
+  * In case of a broadcast Socket, Parent()->ObjectName() is used as source of
+  *the message, this name should be unique.
+  *
+  * \param message message
+  */
+  void SendMessage(std::string message);
+
+  /*!
+  * \brief Send a message
+  *
+  * \param message message
+  * \param message_len message length
+  */
+  void SendMessage(const char *message, size_t message_len);
+
+  /*!
+  * \brief Receive a message
+  *
+  * Receive a message and wait up to timeout. \n
+  * If src and src_len are specified, the source of the message will be
+  * copied in the src buffer. \n
+  * Note that in case of a broadcast socket, own messages are filtered and
+  * are not received.
+  *
+  * \param buf buffer to put the message
+  * \param buf_len buffer length
+  * \param timeout timeout
+  * \param src buffer to put source name
+  * \param src_len buffer length
+  *
+  * \return size of the received message
+  */
+  ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout, char *src = NULL,
+                      size_t *src_len = NULL);
+
+  void NetworkToHost(char *data, size_t dataSize);
+  void HostToNetwork(char *data, size_t dataSize);
+
+private:
+  class UdpSocket_impl *pimpl_;
+};
+
+} // end namespace core
+} // end namespace flair
+
+#endif // UDPSOCKET_H
Index: trunk/lib/FlairCore/src/UdpSocket_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/UdpSocket_impl.cpp	(revision 178)
+++ trunk/lib/FlairCore/src/UdpSocket_impl.cpp	(revision 178)
@@ -0,0 +1,375 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2013/11/17
+//  filename:   Socket_impl.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    classe pour une Socket_impl
+//
+//
+/*********************************************************************/
+#include "UdpSocket_impl.h"
+#include "UdpSocket.h"
+#include "FrameworkManager.h"
+#include <fcntl.h>
+#include <cstdlib>
+#include <unistd.h>
+#include <string.h>
+#ifdef __XENO__
+#include "config.h"
+#endif
+
+using std::string;
+using namespace flair::core;
+
+UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, uint16_t port) {
+  this->self = self;
+  this->port = port;
+  this->address = "";
+  this->broadcast = false;
+  Init();
+}
+
+UdpSocket_impl::UdpSocket_impl(const UdpSocket *self, string name, string address,
+                         bool broadcast) {
+  this->self = self;
+  int pos = address.find(":");
+  this->address = address.substr(0, pos);
+  port = atoi(address.substr(pos + 1).c_str());
+  this->broadcast = broadcast;
+
+  if (pos == 0 || address == "") {
+    self->Err("address %s is not correct\n", address.c_str());
+  }
+  Init();
+}
+
+void UdpSocket_impl::Init(void) {
+  int yes = 1;
+
+  fd = socket(AF_INET, SOCK_DGRAM, 0); // UDP
+
+  if (broadcast == true) {
+    if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(int)) != 0)
+      self->Err("Setsockopt error\n");
+  }
+
+  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0)
+    self->Err("Setsockopt error\n");
+
+  if (address == "" || broadcast == true) {
+    sockaddr_in sin = {0};
+
+    if (broadcast == true) {
+      struct hostent *hostinfo;
+
+      hostinfo = gethostbyname(this->address.c_str());
+      if (hostinfo == NULL) {
+        self->Err("hostinfo error\n");
+      }
+      sin.sin_addr = *(in_addr *)hostinfo->h_addr;
+    } else {
+      sin.sin_addr.s_addr = INADDR_ANY;
+    }
+
+    sin.sin_port = htons(port);
+    sin.sin_family = AF_INET;
+    if (bind(fd, (sockaddr *)&sin, sizeof sin) == -1) {
+      self->Err("bind error\n");
+    }
+  }
+
+#ifdef __XENO__
+  string tmp_name;
+  int status;
+  is_running = true;
+
+  // pipe
+  tmp_name =
+      getFrameworkManager()->ObjectName() + "-" + self->ObjectName() + "-pipe";
+  // xenomai limitation
+  if (tmp_name.size() > 31)
+    self->Err("rt_pipe_create error (%s is too long)\n", tmp_name.c_str());
+#ifdef RT_PIPE_SIZE
+  status = rt_pipe_create(&pipe, tmp_name.c_str(), P_MINOR_AUTO, RT_PIPE_SIZE);
+#else
+  status = rt_pipe_create(&pipe, tmp_name.c_str(), P_MINOR_AUTO, 0);
+#endif
+  if (status != 0) {
+		char errorMsg[256];
+    self->Err("rt_pipe_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+  }
+
+// start user side thread
+#ifdef NRT_STACK_SIZE
+  // Initialize thread creation attributes
+  pthread_attr_t attr;
+  if (pthread_attr_init(&attr) != 0) {
+    self->Err("pthread_attr_init error\n");
+  }
+  if (pthread_attr_setstacksize(&attr, NRT_STACK_SIZE) != 0) {
+    self->Err("pthread_attr_setstacksize error\n");
+  }
+  if (pthread_create(&user_thread, &attr, user, (void *)this) < 0) {
+    self->Err("pthread_create error\n");
+  }
+  if (pthread_attr_destroy(&attr) != 0) {
+    self->Err("pthread_attr_destroy error\n");
+  }
+#else  // NRT_STACK_SIZE
+  if (pthread_create(&user_thread, NULL, user, (void *)this) < 0) {
+    self->Err("pthread_create error\n");
+  }
+#endif // NRT_STACK_SIZE
+#endif //__XENO__
+
+  if (address != "") {
+    struct hostent *hostinfo;
+    hostinfo = gethostbyname(address.c_str());
+    if (hostinfo == NULL) {
+      self->Err("gethostbyname\n");
+    }
+
+    sock_in.sin_addr = *(in_addr *)hostinfo->h_addr;
+    sock_in.sin_port = htons(port);
+    sock_in.sin_family = AF_INET;
+  }
+}
+
+UdpSocket_impl::~UdpSocket_impl() {
+#ifdef __XENO__
+  is_running = false;
+
+  pthread_join(user_thread, NULL);
+  int status = rt_pipe_delete(&pipe);
+  if (status != 0) {
+		char errorMsg[256];
+    self->Err("rt_pipe_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+	}
+#endif
+  close(fd);
+}
+
+void UdpSocket_impl::SendMessage(const char *src, size_t src_len) {
+  ssize_t written;
+  string to_send;
+	char errorMsg[256];
+
+  if (broadcast == true) {
+    to_send = getFrameworkManager()->ObjectName() + ":" + string(src, src_len);
+    src_len = to_send.size();
+    src = (char *)to_send.c_str();
+  }
+
+#ifdef __XENO__
+  // Printf("send pipe %s\n",src);
+  written = rt_pipe_write(&pipe, src, src_len, P_NORMAL);
+
+  if (written < 0) {
+    self->Err("rt_pipe_write error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
+  } else if (written != (ssize_t)src_len) {
+    self->Err("rt_pipe_write error %i/%i\n", written, to_send.size());
+  }
+#else
+  written =
+      sendto(fd, src, src_len, 0, (struct sockaddr *)&sock_in, sizeof(sock_in));
+  if(written==-1) {
+		char errorMsg[256];
+    self->Err("sendto error (%s)\n",strerror_r(errno, errorMsg, sizeof(errorMsg)));
+  } else if (written != (ssize_t)src_len) {
+    self->Err("sendto error %i/%i\n",written,src_len);
+  }
+#endif
+}
+
+void UdpSocket_impl::SendMessage(string message) {
+  ssize_t written;
+
+  if (broadcast == true)
+    message = self->Parent()->ObjectName() + ":" + message;
+// Printf("SendMessage %s\n",message.c_str());
+#ifdef __XENO__
+  written = rt_pipe_write(&pipe, message.c_str(), message.size(), P_NORMAL);
+
+  if (written < 0) {
+		char errorMsg[256];
+    self->Err("rt_pipe_write error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
+  } else if (written != (ssize_t)message.size()) {
+    self->Err("rt_pipe_write error %i/%i\n", written, message.size());
+  }
+#else
+  written = sendto(fd, message.c_str(), message.size(), 0,
+                   (struct sockaddr *)&sock_in, sizeof(sock_in));
+  if (written != (ssize_t)message.size()) {
+    self->Err("sendto error\n");
+  }
+
+#endif
+}
+
+ssize_t UdpSocket_impl::RecvMessage(char *msg, size_t msg_len, Time timeout,
+                                 char *src, size_t *src_len) {
+  ssize_t nb_read;
+  char buffer[128];
+#ifdef __XENO__
+  nb_read = rt_pipe_read(&pipe, &buffer, sizeof(buffer), timeout);
+#else
+  socklen_t sinsize = sizeof(sock_in);
+  struct timeval tv;
+
+  if (timeout != TIME_NONBLOCK) {
+    int attr = fcntl(fd, F_GETFL, 0);
+    fcntl(fd, F_SETFL, attr & (~O_NONBLOCK));
+
+    tv.tv_sec = timeout / 1000000000;
+    timeout = timeout - (timeout / 1000000000) * 1000000000;
+    tv.tv_usec = timeout / 1000;
+    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
+      self->Err("setsockopt SO_RCVTIMEO failed\n");
+    }
+  } else {
+    fcntl(fd, F_SETFL, O_NONBLOCK);
+  }
+
+  if (broadcast == false) {
+    nb_read =
+        recvfrom(fd, buffer, sizeof(buffer), 0, (sockaddr *)&sock_in, &sinsize);
+  } else {
+    nb_read = recvfrom(fd, buffer, sizeof(buffer), 0, NULL, NULL);
+  }
+#endif
+  if (nb_read <= 0) {
+    return nb_read;
+  } else {
+    // printf("%s\n",buffer);
+    if (broadcast == true) {
+      int index = -1;
+      for (int i = 0; i < nb_read; i++) {
+        if (buffer[i] == ':') {
+          index = i;
+          break;
+        }
+      }
+      if (index < 0) {
+        self->Warn("Malformed message\n");
+        return -1;
+      } else if (src_len != NULL && src != NULL) {
+        if (index + 1 > (int)(*src_len) &&
+            src != NULL) { //+1 pour inserer un 0)
+          self->Warn("insufficent src size\n");
+          return -1;
+        }
+      } else if (nb_read - index - 1 + 1 >
+                 (int)msg_len) { //+1 pour inserer un 0
+        self->Warn("insufficent msg size (%i/%i)\n", nb_read - index - 1 + 1,
+                   msg_len);
+        return -1;
+      }
+      if (src != NULL) {
+        memcpy(src, buffer, index);
+        src[index] = 0;
+      }
+      memcpy(msg, &buffer[index + 1], nb_read - index - 1);
+      msg[nb_read - index - 1] = 0;
+      return nb_read - index;
+    } else {
+      if (nb_read > (int)msg_len) {
+        self->Warn("insufficent msg size (%i/%i)\n", nb_read, msg_len);
+        return -1;
+      }
+      memcpy(msg, buffer, nb_read);
+      return nb_read;
+    }
+  }
+}
+
+#ifdef __XENO__
+void *UdpSocket_impl::user(void *arg) {
+  UdpSocket_impl *caller = (UdpSocket_impl *)arg;
+  int pipe_fd = -1;
+  string devname;
+
+  devname = NRT_PIPE_PATH + getFrameworkManager()->ObjectName() + "-" +
+            caller->self->ObjectName() + "-pipe";
+  while (pipe_fd < 0) {
+    pipe_fd = open(devname.c_str(), O_RDWR);
+    if (pipe_fd < 0 && errno != ENOENT) {
+			char errorMsg[256];
+			caller->self->Err("open pipe_fd error (%s)\n", strerror_r(errno, errorMsg, sizeof(errorMsg)));
+		}
+    usleep(1000);
+  }
+
+  while (caller->is_running == true) {
+    fd_set set;
+    struct timeval timeout;
+    int rv;
+
+    FD_ZERO(&set);            // clear the set
+    FD_SET(caller->fd, &set); // add our file descriptor to the set
+    FD_SET(pipe_fd, &set);    // add our file descriptor to the set
+
+    timeout.tv_sec = 0;
+    timeout.tv_usec = SELECT_TIMEOUT_MS * 1000;
+    rv = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
+
+    if (rv == -1) {
+      caller->self->Err("select error\n"); // an error occured
+    } else if (rv == 0) {
+      // printf("timeout\n");
+    } else {
+      ssize_t nb_read, nb_write;
+      char buffer[1024];
+
+      if (FD_ISSET(caller->fd, &set)) {
+        socklen_t sinsize = sizeof(caller->sock_in);
+        if (caller->broadcast == false) {
+          nb_read = recvfrom(caller->fd, buffer, sizeof(buffer), 0,
+                             (sockaddr *)&(caller->sock_in), &sinsize);
+        } else {
+          nb_read = recvfrom(caller->fd, buffer, sizeof(buffer), 0, NULL, NULL);
+        }
+        if (nb_read < 0) {
+          caller->self->Err("recvfrom error\n");
+        }
+        // printf("user %s\n",buffer);
+        // on ne garde que les messages venant pas de soi meme
+        if (caller->broadcast == false ||
+            (caller->broadcast == true &&
+             getFrameworkManager()->ObjectName().compare(
+                 0, getFrameworkManager()->ObjectName().size(), buffer,
+                 getFrameworkManager()->ObjectName().size()) != 0)) {
+          nb_write = write(pipe_fd, buffer, nb_read);
+          if (nb_write != nb_read) {
+            caller->self->Err("write error\n");
+          }
+        } else {
+          // printf("self %s\n",buffer);
+        }
+      }
+      if (FD_ISSET(pipe_fd, &set)) {
+        nb_read = read(pipe_fd, buffer, sizeof(buffer));
+        // printf("read pipe %i %s\n",nb_read,buffer);
+        if (nb_read > 0) {
+          // printf("send %s\n",buffer);
+          nb_write = sendto(caller->fd, buffer, nb_read, 0,
+                            (struct sockaddr *)&(caller->sock_in),
+                            sizeof(caller->sock_in));
+          if (nb_write != nb_read) {
+            caller->self->Err("sendto error\n");
+          }
+        }
+      }
+    }
+  }
+
+  close(pipe_fd);
+  pthread_exit(0);
+}
+#endif
Index: trunk/lib/FlairCore/src/unexported/Socket_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/Socket_impl.h	(revision 177)
+++ 	(revision )
@@ -1,57 +1,0 @@
-// %flair:license{
-// This file is part of the Flair framework distributed under the
-// CECILL-C License, Version 1.0.
-// %flair:license}
-/*!
- * \file Socket_impl.h
- * \brief Classe creant une socket
- * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
- * \date 2013/11/17
- * \version 4.0
- */
-
-#ifndef SOCKET_IMPL_H
-#define SOCKET_IMPL_H
-
-#include <sys/socket.h>
-#include <netdb.h>
-#include <Object.h>
-#ifdef __XENO__
-#include <native/pipe.h>
-#endif
-
-namespace flair {
-namespace core {
-class Socket;
-}
-}
-
-class Socket_impl {
-public:
-  Socket_impl(const flair::core::Socket *self, std::string name,
-              std::string address, bool broadcast = false);
-  Socket_impl(const flair::core::Socket *self, std::string name, uint16_t port);
-  ~Socket_impl();
-
-  void SendMessage(std::string message);
-  void SendMessage(const char *src, size_t src_len);
-  ssize_t RecvMessage(char *msg, size_t msg_len, flair::core::Time timeout,
-                      char *src = NULL, size_t *src_len = NULL);
-
-private:
-  int fd;
-  uint16_t port;
-  std::string address;
-  bool broadcast;
-  void Init(void);
-  const flair::core::Socket *self;
-  struct sockaddr_in sock_in;
-#ifdef __XENO__
-  bool is_running;
-  static void *user(void *arg);
-  pthread_t user_thread;
-  RT_PIPE pipe;
-#endif
-};
-
-#endif // SOCKET_IMPL_H
Index: trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h	(revision 178)
+++ trunk/lib/FlairCore/src/unexported/UdpSocket_impl.h	(revision 178)
@@ -0,0 +1,55 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file UdpSocket_impl.h
+ * \brief Classe creant une socket
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2013/11/17
+ * \version 4.0
+ */
+
+#ifndef UDPSOCKET_IMPL_H
+#define UDPSOCKET_IMPL_H
+
+#include <sys/socket.h>
+#include <netdb.h>
+#include <Object.h>
+#ifdef __XENO__
+#include <native/pipe.h>
+#endif
+
+namespace flair { namespace core {
+  class UdpSocket;
+} }
+
+class UdpSocket_impl {
+public:
+  UdpSocket_impl(const flair::core::UdpSocket *self, std::string name,
+              std::string address, bool broadcast = false);
+  UdpSocket_impl(const flair::core::UdpSocket *self, std::string name, uint16_t port);
+  ~UdpSocket_impl();
+
+  void SendMessage(std::string message);
+  void SendMessage(const char *src, size_t src_len);
+  ssize_t RecvMessage(char *msg, size_t msg_len, flair::core::Time timeout,
+                      char *src = NULL, size_t *src_len = NULL);
+
+private:
+  int fd;
+  uint16_t port;
+  std::string address;
+  bool broadcast;
+  void Init(void);
+  const flair::core::UdpSocket *self;
+  struct sockaddr_in sock_in;
+#ifdef __XENO__
+  bool is_running;
+  static void *user(void *arg);
+  pthread_t user_thread;
+  RT_PIPE pipe;
+#endif
+};
+
+#endif // UDPSOCKET_IMPL_H
Index: trunk/lib/FlairSensorActuator/src/EmulatedController.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/EmulatedController.cpp	(revision 177)
+++ trunk/lib/FlairSensorActuator/src/EmulatedController.cpp	(revision 178)
@@ -14,5 +14,5 @@
 #include <Controller.h>
 #include <TcpSocket.h>
-#include <Socket.h>
+#include <UdpSocket.h>
 #include <cstring>
 #include <string>
Index: trunk/lib/FlairSensorActuator/src/HostEthController.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/HostEthController.cpp	(revision 177)
+++ trunk/lib/FlairSensorActuator/src/HostEthController.cpp	(revision 178)
@@ -26,5 +26,5 @@
 #include <TargetController.h>
 #include <TcpSocket.h>
-#include <Socket.h>
+#include <UdpSocket.h>
 #include <cstring>
 #include <string>
@@ -54,5 +54,5 @@
   controlSocket = new TcpSocket((Thread *)this, "eth controller control socket",
                                 blocking, !blocking);
-  dataSocket = new Socket((Thread *)this, "eth controller data socket",
+  dataSocket = new UdpSocket((Thread *)this, "eth controller data socket",
                           _address + ":" + std::to_string(_port + 1));
   dataSender =
Index: trunk/lib/FlairSensorActuator/src/HostEthController.h
===================================================================
--- trunk/lib/FlairSensorActuator/src/HostEthController.h	(revision 177)
+++ trunk/lib/FlairSensorActuator/src/HostEthController.h	(revision 178)
@@ -28,5 +28,5 @@
 class cvmatrix;
 class TcpSocket;
-class Socket;
+class UdpSocket;
 class Mutex;
 }
@@ -64,5 +64,5 @@
   std::string controllerName;
   core::TcpSocket *controlSocket; // connection to the target
-  core::Socket *dataSocket;
+  core::UdpSocket *dataSocket;
   std::string targetAddress;
   int targetPort;
Index: trunk/lib/FlairSensorActuator/src/TargetEthController.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/TargetEthController.cpp	(revision 177)
+++ trunk/lib/FlairSensorActuator/src/TargetEthController.cpp	(revision 178)
@@ -21,5 +21,5 @@
 #include <FrameworkManager.h>
 #include <TcpSocket.h>
-#include <Socket.h>
+#include <UdpSocket.h>
 #include <cstring>
 #include <string>
@@ -44,5 +44,5 @@
       new TcpSocket(getFrameworkManager(), "TEC_listening_socket", blocking, blocking);
   dataSocket =
-      new Socket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side
+      new UdpSocket(getFrameworkManager(), "TEC_data_socket", _port + 1); // receiving side
 }
 
Index: trunk/lib/FlairSensorActuator/src/TargetEthController.h
===================================================================
--- trunk/lib/FlairSensorActuator/src/TargetEthController.h	(revision 177)
+++ trunk/lib/FlairSensorActuator/src/TargetEthController.h	(revision 178)
@@ -29,5 +29,5 @@
 class cvmatrix;
 class TcpSocket;
-class Socket;
+class UdpSocket;
 }
 namespace gui {
@@ -78,5 +78,5 @@
   int listeningPort;
   core::TcpSocket *controlSocket = NULL;
-  core::Socket *dataSocket;
+  core::UdpSocket *dataSocket;
   std::string *axisName = NULL;
   std::string *buttonName = NULL;
