Index: trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 231)
+++ trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 234)
@@ -193,8 +193,4 @@
       Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
 
-    status = UDT::close(file_sock);
-    if (status != 0)
-      Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
-
     SleepMS(200); // a revoir, sinon UDT::cleanup bloque en RT
     UDT::cleanup();
@@ -210,4 +206,6 @@
     return;
   }
+  this->address=address;
+  this->port=port;
 																							
 	UDT::startup(1024*256,1024*256,1024*256);
@@ -216,6 +214,6 @@
   // socket file_socket, doit être créé en premier, cf station sol
   Printf("Connecting to %s:%i\n", address.c_str(), port);
-  file_sock = GetSocket(address, port);
-  com_sock = GetSocket(address, port);
+  //file_sock = GetSocket(address, port);
+  com_sock = GetSocket();
 
   // receive buffer allocation
@@ -226,12 +224,4 @@
 
   com = new ui_com(this, com_sock);
-
-  // file managment
-  bool blocking = true;
-  UDT::setsockopt(file_sock, 0, UDT_SNDSYN, &blocking, sizeof(bool));
-  UDT::setsockopt(file_sock, 0, UDT_RCVSYN, &blocking, sizeof(bool));
-
-  int timeout = 100; // ms
-  UDT::setsockopt(com_sock, 0, UDT_RCVTIMEO, &timeout, sizeof(int));
 
   Start();
@@ -292,14 +282,14 @@
   while (!ToBeStopped()) {
     ssize_t bytesRead;
-
     bytesRead = com->Receive(rcv_buf, rcv_buf_size);
-
+    com->CheckConnection();
+//printf("%i\n",bytesRead);
     if (bytesRead == (ssize_t)rcv_buf_size)
       Err("FrameworkManager max receive size, augmenter le buffer size!\n");
 
     if (bytesRead > 0) {
-      // printf("recu %ld, trame %x\n",bytesRead,(uint8_t)rcv_buf[0]);
-      // rcv_buf[bytesRead-1]=0;//pour affichage
-      // printf("%s\n",rcv_buf);
+       //printf("recu %ld, trame %x %lld\n",bytesRead,(uint8_t)rcv_buf[0],GetTime()/(1000000));
+       //rcv_buf[bytesRead-1]=0;//pour affichage
+       //printf("%s\n",rcv_buf);
 
       switch ((uint8_t)rcv_buf[0]) {
@@ -376,5 +366,5 @@
 }
 
-void FrameworkManager_impl::SendFile(string path, string name) {
+void FrameworkManager_impl::SendFile(UDTSOCKET socket,string path, string name) {
   char *buf, *more_buf;
   int size;
@@ -411,5 +401,5 @@
   Printf("sending %s, size: %i\n", filename.c_str(), size);
   // send file information
-  UDT::sendmsg(file_sock, buf, sizeof(uint8_t) + sizeof(int) + name.size(), -1,true);
+  UDT::sendmsg(socket, buf, sizeof(uint8_t) + sizeof(int) + name.size(), -1,true);
 
   more_buf = (char *)realloc((void *)buf, size);
@@ -424,5 +414,5 @@
   pbuf->sgetn(buf, size);
   // send the file
-  nb_write = UDT::sendmsg(file_sock, buf, size, -1, true);
+  nb_write = UDT::sendmsg(socket, buf, size, -1, true);
 
   if (nb_write < 0) {
@@ -436,9 +426,9 @@
 }
 
-void FrameworkManager_impl::FinishSending() {
+void FrameworkManager_impl::FinishSending(UDTSOCKET socket) {
   char rm_cmd[256];
 
   // send orignal xml
-  SendFile(log_path, "setup.xml");
+  SendFile(socket,log_path, "setup.xml");
   sprintf(rm_cmd, "rm %s/setup.xml", log_path.c_str());
   system(rm_cmd);
@@ -447,5 +437,5 @@
   for (size_t i = 0; i < xml_changes.size(); i++) {
     // Printf("%s\n",xml_changes.at(i).c_str());
-    SendFile(log_path, xml_changes.at(i).c_str());
+    SendFile(socket,log_path, xml_changes.at(i).c_str());
     sprintf(rm_cmd, "rm %s/%s", log_path.c_str(), xml_changes.at(i).c_str());
     system(rm_cmd);
@@ -454,6 +444,6 @@
 
   // end notify
-  char buf = END;
-  int nb_write = UDT::sendmsg(file_sock, &buf, 1, -1, true);
+  char buf = END_SENDING_FILES;
+  int nb_write = UDT::sendmsg(socket, &buf, 1, -1, true);
 
   if (nb_write < 0) {
@@ -464,5 +454,5 @@
 
   //wait end ACK
-  int nb_read = UDT::recvmsg(file_sock,&buf,1);
+  int nb_read = UDT::recvmsg(socket,&buf,1);
   if(nb_read<0) {
     Err("UDT::recvmsg error (%s)\n",UDT::getlasterror().getErrorMessage());
@@ -472,5 +462,5 @@
 }
 
-UDTSOCKET FrameworkManager_impl::GetSocket(string address, uint16_t port) {
+UDTSOCKET FrameworkManager_impl::GetSocket(void) {
   while (1) {
     UDTSOCKET new_fd;
@@ -854,4 +844,17 @@
               caller->gcs_watchdog->Join();
           }
+          //create a socket for files
+          UDTSOCKET file_sock = caller->GetSocket();
+          char data=START_SENDING_FILES;
+          ssize_t nb_write = UDT::sendmsg(file_sock, &data, 1, -1, true);
+          if (nb_write < 0) {
+            caller->Err("UDT::sendmsg error (%s)\n", UDT::getlasterror().getErrorMessage());
+            if (UDT::getlasterror().getErrorCode() == CUDTException::ECONNLOST ||
+                UDT::getlasterror().getErrorCode() == CUDTException::EINVSOCK) {
+            }
+          } else if (nb_write != 1) {
+            caller->Err("%s, code %i (%ld/%ld)\n", UDT::getlasterror().getErrorMessage(),
+                UDT::getlasterror().getErrorCode(), nb_write, 1);
+          }
           for (size_t i = 0; i < logs.size(); i++) {
             if (logs.at(i).dbtFile != NULL) {
@@ -859,5 +862,5 @@
 
               string filename = caller->FileName(logs.at(i).device) + ".dbt";
-              caller->SendFile(caller->log_path, filename);
+              caller->SendFile(file_sock,caller->log_path, filename);
 
               fstream txt_file;
@@ -870,10 +873,14 @@
               txt_file.close();
 
-              caller->SendFile(caller->log_path, filename);
+              caller->SendFile(file_sock,caller->log_path, filename);
             }
           }
           // a revoir celui ci est le xml enregistré et pas forcement l'actuel
           // if(caller->xml_file!="") caller->SendFile(caller->xml_file);
-          caller->FinishSending();
+          caller->FinishSending(file_sock);
+          
+          int status = UDT::close(file_sock);
+          if (status != 0)
+            caller->Err("Error udt::close %s", UDT::getlasterror().getErrorMessage());
 
           logs.clear();
Index: trunk/lib/FlairCore/src/ui_com.cpp
===================================================================
--- trunk/lib/FlairCore/src/ui_com.cpp	(revision 231)
+++ trunk/lib/FlairCore/src/ui_com.cpp	(revision 234)
@@ -223,4 +223,14 @@
 }
 
+void ui_com::CheckConnection(void) {
+  int32_t val,len;
+  
+  int result=UDT::getsockopt(socket_fd,0,UDT_STATE,&val,&len); 
+   if (result < 0) {
+    Printf("UDT::getsockopt error (%s)\n", UDT::getlasterror().getErrorMessage());
+   }
+ // printf("opt: %i %i %i\n",result,val,len);
+}
+
 void ui_com::Run(void) {
   // check endianness
Index: trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h	(revision 231)
+++ trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h	(revision 234)
@@ -82,9 +82,9 @@
 private:
   flair::core::FrameworkManager *self;
-  UDTSOCKET file_sock, com_sock;
-  UDTSOCKET GetSocket(std::string address, uint16_t port);
+  UDTSOCKET com_sock;
+  UDTSOCKET GetSocket(void);
   void Run();
-  void SendFile(std::string path, std::string name);
-  void FinishSending(void);
+  void SendFile(UDTSOCKET socket,std::string path, std::string name);
+  void FinishSending(UDTSOCKET socket);
   std::string FileName(flair::core::IODevice *device);
   void SaveXmlChange(char *buf);
@@ -92,4 +92,6 @@
   size_t rcv_buf_size;
   char *rcv_buf;
+  std::string address;
+  uint16_t port;
 #ifdef __XENO__
   int CreatePipe(RT_PIPE *fd, std::string name);
Index: trunk/lib/FlairCore/src/unexported/communication.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/communication.h	(revision 231)
+++ trunk/lib/FlairCore/src/unexported/communication.h	(revision 234)
@@ -6,15 +6,15 @@
 #define COMMUNICATION_H
 
-// messages file socket
-#define FILE_INFO_LITTLE_ENDIAN 0x01
-#define FILE_INFO_BIG_ENDIAN 0x02
-#define END 0x03
-
+// messages data socket
 #define XML_HEADER 0x3c
 #define ZLIB_HEADER 0x78
 #define WATCHDOG_HEADER 0x01
+#define DATAS_LITTLE_ENDIAN 0x02
+#define DATAS_BIG_ENDIAN 0x03
 
-#define DATAS_LITTLE_ENDIAN 0xfd
-#define DATAS_BIG_ENDIAN 0xfe
+#define START_SENDING_FILES 0x10
+#define FILE_INFO_LITTLE_ENDIAN 0x11
+#define FILE_INFO_BIG_ENDIAN 0x12
+#define END_SENDING_FILES 0x13
 
 #endif // COMMUNICATION_H
Index: trunk/lib/FlairCore/src/unexported/ui_com.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/ui_com.h	(revision 231)
+++ trunk/lib/FlairCore/src/unexported/ui_com.h	(revision 234)
@@ -48,5 +48,5 @@
   void UnBlock(void);
   bool ConnectionLost(void);
-
+  void CheckConnection(void);
 private:
   ssize_t send_size;
