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; }
int send_message(e_mc_message_type message_id) { return MC_protocol_send_simple_message(this->socket_, message_id); }