+/** \brief Waits for a message to come in over a given socket.
+ *
+ * @param timeout: How long should we wait for this message.
+ * @param msgt_want: type of awaited msg
+ * @param[out] expeditor: where to create a socket to answer the incomming message
+ * @param[out] payload: where to write the payload of the incomming message
+ * @return the error code (or no_error).
+ *
+ * Every message of another type received before the one waited will be queued
+ * and used by subsequent call to this function or gras_msg_handle().
+ */
+void
+gras_msg_wait(double timeout,
+ gras_msgtype_t msgt_want,
+ gras_socket_t *expeditor,
+ void *payload) {
+ s_gras_msg_t msg;
+
+ gras_msg_wait_ext(timeout,
+ msgt_want, NULL, NULL, NULL,
+ &msg);
+
+ if (msgt_want->ctn_type) {
+ xbt_assert1(payload,
+ "Message type '%s' convey a payload you must accept",
+ msgt_want->name);
+ } else {
+ xbt_assert1(!payload,
+ "No payload was declared for message type '%s'",
+ msgt_want->name);
+ }
+
+ if (payload) {
+ memcpy(payload,msg.payl,msg.payl_size);
+ free(msg.payl);
+ }
+
+ if (expeditor)
+ *expeditor = msg.expe;
+}
+
+
+/** \brief Send the data pointed by \a payload as a message of type
+ * \a msgtype to the peer \a sock */
+void
+gras_msg_send(gras_socket_t sock,
+ gras_msgtype_t msgtype,
+ void *payload) {
+
+ if (msgtype->ctn_type) {
+ xbt_assert1(payload,
+ "Message type '%s' convey a payload you must provide",
+ msgtype->name);
+ } else {
+ xbt_assert1(!payload,
+ "No payload was declared for message type '%s'",
+ msgtype->name);
+ }
+
+ gras_msg_send_ext(sock, e_gras_msg_kind_oneway,0, msgtype, payload);
+}
+
+/** @brief Handle all messages arriving within the given period
+ *
+ * @param timeOut: How long to wait for incoming messages (in seconds)
+ * @return the error code (or no_error).
+ *
+ * Messages are dealed with just like gras_msg_handle() would do. The
+ * difference is that gras_msg_handle() handles at most one message (or wait up
+ * to timeout second when no message arrives) while this function handles any
+ * amount of messages, and lasts the given period in any case.
+ */
+void
+gras_msg_handleall(double period) {
+ xbt_ex_t e;
+ double begin=gras_os_time();
+ double now;