Example #1
0
int MC_protocol_hello(int socket)
{
  int e;
  if ((e = MC_protocol_send_simple_message(socket, MC_MESSAGE_HELLO)) != 0) {
    XBT_ERROR("Could not send HELLO message");
    return 1;
  }

  s_mc_message_t message;
  message.type = MC_MESSAGE_NONE;

  ssize_t s;
  while ((s = MC_receive_message(socket, &message, sizeof(message), 0)) == -1) {
    if (errno == EINTR)
      continue;
    else {
      XBT_ERROR("Could not receive HELLO message");
      return 2;
    }
  }
  if ((size_t) s < sizeof(message) || message.type != MC_MESSAGE_HELLO) {
    XBT_ERROR("Did not receive suitable HELLO message. Who are you?");
    return 3;
  }

  return 0;
}
Example #2
0
 typename std::enable_if< std::is_class<M>::value && std::is_trivial<M>::value, ssize_t >::type
 receive_message(M& m)
 {
   return MC_receive_message(this->socket_, &m, sizeof(M), 0);
 }