Index: /XIOS/trunk/src/context_client.cpp
===================================================================
--- /XIOS/trunk/src/context_client.cpp	(revision 1032)
+++ /XIOS/trunk/src/context_client.cpp	(revision 1033)
@@ -85,22 +85,68 @@
     {
       list<int> ranks = event.getRanks();
+
       if (!event.isEmpty())
       {
         list<int> sizes = event.getSizes();
 
-        list<CBufferOut*> buffList = getBuffers(ranks, sizes);
-
-        event.send(timeLine, sizes, buffList);
-
-        checkBuffers(ranks);
-      }
-
-      if (isAttachedModeEnabled())
-      {
-        waitEvent(ranks);
-        CContext::setCurrent(context->getId());
+        // We force the getBuffers call to be non-blocking on the servers
+        list<CBufferOut*> buffList;
+        bool couldBuffer = getBuffers(ranks, sizes, buffList, !CXios::isClient);
+
+        if (couldBuffer)
+        {
+          event.send(timeLine, sizes, buffList);
+
+          checkBuffers(ranks);
+
+          if (isAttachedModeEnabled()) // couldBuffer is always true in attached mode
+          {
+            waitEvent(ranks);
+            CContext::setCurrent(context->getId());
+          }
+        }
+        else
+        {
+          tmpBufferedEvent.ranks = ranks;
+          tmpBufferedEvent.sizes = sizes;
+
+          for (list<int>::const_iterator it = sizes.begin(); it != sizes.end(); it++)
+            tmpBufferedEvent.buffers.push_back(new CBufferOut(*it));
+
+          event.send(timeLine, tmpBufferedEvent.sizes, tmpBufferedEvent.buffers);
+        }
       }
 
       timeLine++;
+    }
+
+    /*!
+     * Send the temporarily buffered event (if any).
+     *
+     * \return true if a temporarily buffered event could be sent, false otherwise 
+     */
+    bool CContextClient::sendTemporarilyBufferedEvent()
+    {
+      bool couldSendTmpBufferedEvent = false;
+
+      if (hasTemporarilyBufferedEvent())
+      {
+        list<CBufferOut*> buffList;
+        if (getBuffers(tmpBufferedEvent.ranks, tmpBufferedEvent.sizes, buffList, true)) // Non-blocking call
+        {
+          list<CBufferOut*>::iterator it, itBuffer;
+
+          for (it = tmpBufferedEvent.buffers.begin(), itBuffer = buffList.begin(); it != tmpBufferedEvent.buffers.end(); it++, itBuffer++)
+            (*itBuffer)->put((char*)(*it)->start(), (*it)->count());
+
+          checkBuffers(tmpBufferedEvent.ranks);
+
+          tmpBufferedEvent.clear();
+
+          couldSendTmpBufferedEvent = true;
+        }
+      }
+
+      return couldSendTmpBufferedEvent;
     }
 
@@ -126,16 +172,19 @@
 
     /*!
-    Setup buffer for each connection to server and verify their state to put content into them
-    \param [in] serverList list of rank of connected server
-    \param [in] sizeList size of message corresponding to each connection
-    \return List of buffer input which event can be placed
+     * Get buffers for each connection to the servers. This function blocks until there is enough room in the buffers unless
+     * it is explicitly requested to be non-blocking.
+     *
+     * \param [in] serverList list of rank of connected server
+     * \param [in] sizeList size of message corresponding to each connection
+     * \param [out] retBuffers list of buffers that can be used to store an event
+     * \param [in] nonBlocking whether this function should be non-blocking
+     * \return whether the already allocated buffers could be used
     */
-    list<CBufferOut*> CContextClient::getBuffers(list<int>& serverList, list<int>& sizeList)
+    bool CContextClient::getBuffers(const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking /*= false*/)
     {
-      list<int>::iterator itServer, itSize;
+      list<int>::const_iterator itServer, itSize;
       list<CClientBuffer*> bufferList;
-      map<int,CClientBuffer*>::iterator it;
+      map<int,CClientBuffer*>::const_iterator it;
       list<CClientBuffer*>::iterator itBuffer;
-      list<CBufferOut*>  retBuffer;
       bool areBuffersFree;
 
@@ -163,12 +212,14 @@
           context->server->listen();
         }
-      } while (!areBuffersFree);
+      } while (!areBuffersFree && !nonBlocking);
       CTimer::get("Blocking time").suspend();
 
-      for (itBuffer = bufferList.begin(), itSize = sizeList.begin(); itBuffer != bufferList.end(); itBuffer++, itSize++)
-      {
-        retBuffer.push_back((*itBuffer)->getBuffer(*itSize));
-      }
-      return retBuffer;
+      if (areBuffersFree)
+      {
+        for (itBuffer = bufferList.begin(), itSize = sizeList.begin(); itBuffer != bufferList.end(); itBuffer++, itSize++)
+          retBuffers.push_back((*itBuffer)->getBuffer(*itSize));
+      }
+
+      return areBuffersFree;
    }
 
@@ -303,5 +354,13 @@
    {
      map<int,CClientBuffer*>::iterator itBuff;
-     bool stop = true;
+     bool stop = false;
+
+     CTimer::get("Blocking time").resume();
+     while (hasTemporarilyBufferedEvent())
+     {
+       checkBuffers();
+       sendTemporarilyBufferedEvent();
+     }
+     CTimer::get("Blocking time").suspend();
 
      CEventClient event(CContext::GetType(), CContext::EVENT_ID_CONTEXT_FINALIZE);
@@ -317,9 +376,12 @@
 
      CTimer::get("Blocking time").resume();
-     while (stop)
+     while (!stop)
      {
        checkBuffers();
-       stop = false;
-       for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) stop |= itBuff->second->hasPendingRequest();
+       if (hasTemporarilyBufferedEvent())
+         sendTemporarilyBufferedEvent();
+
+       stop = true;
+       for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) stop &= !itBuff->second->hasPendingRequest();
      }
      CTimer::get("Blocking time").suspend();
Index: /XIOS/trunk/src/context_client.hpp
===================================================================
--- /XIOS/trunk/src/context_client.hpp	(revision 1032)
+++ /XIOS/trunk/src/context_client.hpp	(revision 1033)
@@ -31,8 +31,9 @@
       // Send event to server
       void sendEvent(CEventClient& event);
+      bool sendTemporarilyBufferedEvent();
       void waitEvent(list<int>& ranks);
 
-      // Functions relates to set/get buffers
-      list<CBufferOut*> getBuffers(list<int>& serverlist, list<int>& sizeList);
+      // Functions to set/get buffers
+      bool getBuffers(const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking = false);
       void newBuffer(int rank);
       bool checkBuffers(list<int>& ranks);
@@ -46,4 +47,6 @@
 
       bool isAttachedModeEnabled() const;
+
+      bool hasTemporarilyBufferedEvent() const { return !tmpBufferedEvent.isEmpty(); };
 
       // Close and finalize context client
@@ -76,4 +79,20 @@
       StdSize maxBufferedEvents;
 
+      struct {
+        std::list<int> ranks, sizes;
+        std::list<CBufferOut*> buffers;
+
+        bool isEmpty() const { return ranks.empty(); };
+        void clear() {
+          ranks.clear();
+          sizes.clear();
+
+          for (std::list<CBufferOut*>::iterator it = buffers.begin(); it != buffers.end(); it++)
+            delete *it;
+
+          buffers.clear();
+        };
+      } tmpBufferedEvent; //! Event temporarily buffered (used only on the server)
+
       //! Context for server (Only used in attached mode)
       CContext* parentServer;
Index: /XIOS/trunk/src/context_server.cpp
===================================================================
--- /XIOS/trunk/src/context_server.cpp	(revision 1032)
+++ /XIOS/trunk/src/context_server.cpp	(revision 1033)
@@ -57,9 +57,10 @@
   }
 
-  bool CContextServer::eventLoop(void)
+  bool CContextServer::eventLoop(bool enableEventsProcessing /*= true*/)
   {
     listen();
     checkPendingRequest();
-    processEvents();
+    if (enableEventsProcessing)
+      processEvents();
     return finished;
   }
Index: /XIOS/trunk/src/context_server.hpp
===================================================================
--- /XIOS/trunk/src/context_server.hpp	(revision 1032)
+++ /XIOS/trunk/src/context_server.hpp	(revision 1033)
@@ -15,5 +15,5 @@
 
     CContextServer(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) ;
-    bool eventLoop(void) ;
+    bool eventLoop(bool enableEventsProcessing = true);
     void listen(void) ;
     void checkPendingRequest(void) ;
Index: /XIOS/trunk/src/node/context.cpp
===================================================================
--- /XIOS/trunk/src/node/context.cpp	(revision 1032)
+++ /XIOS/trunk/src/node/context.cpp	(revision 1033)
@@ -339,15 +339,15 @@
    }
 
-   //! Server side: Put server into a loop in order to listen message from client
-   bool CContext::eventLoop(void)
-   {
-     return server->eventLoop();
-   }
-
    //! Try to send the buffers and receive possible answers
    bool CContext::checkBuffersAndListen(void)
    {
      client->checkBuffers();
-     return server->eventLoop();
+
+     bool hasTmpBufferedEvent = client->hasTemporarilyBufferedEvent();
+     if (hasTmpBufferedEvent)
+       hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent();
+
+     // Don't process events if there is a temporarily buffered event
+     return server->eventLoop(!hasTmpBufferedEvent);
    }
 
Index: /XIOS/trunk/src/node/context.hpp
===================================================================
--- /XIOS/trunk/src/node/context.hpp	(revision 1032)
+++ /XIOS/trunk/src/node/context.hpp	(revision 1033)
@@ -93,6 +93,4 @@
 
          // Put sever or client into loop state
-         bool eventLoop(void);
-
          bool checkBuffersAndListen(void);
 
