+/** \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);
+ }
+
+ DEBUG2("Send a oneway message of type '%s'. Payload=%p",
+ msgtype->name,payload);
+ gras_msg_send_ext(sock, e_gras_msg_kind_oneway,0, msgtype, payload);
+ VERB2("Sent a oneway message of type '%s'. Payload=%p",
+ msgtype->name,payload);
+}
+
+/** @brief Handle all messages arriving within the given period
+ *
+ * @param period: How long to wait for incoming messages (in seconds)
+ *
+ * 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;
+
+ do {
+ now=gras_os_time();
+ TRY{
+ if (period - now + begin > 0)
+ gras_msg_handle(period - now + begin);
+ } CATCH(e) {
+ if (e.category != timeout_error)
+ RETHROW0("Error while waiting for messages: %s");
+ xbt_ex_free(e);
+ }
+ } while (now - begin < period);
+}
+
+/** @brief Handle an incomming message or timer (or wait up to \a timeOut seconds)
+ *
+ * @param timeOut: How long to wait for incoming messages (in seconds)
+ * @return the error code (or no_error).
+ *
+ * Messages are passed to the callbacks. See also gras_msg_handleall().
+ */
+void
+gras_msg_handle(double timeOut) {
+
+ double untiltimer;
+
+ int cpt, ran_ok;