1 /* Copyright (c) 2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include <sys/types.h>
11 #include <sys/socket.h>
15 #include "mc_protocol.h"
17 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_protocol, mc, "Generic MC protocol logic");
19 int MC_protocol_send_simple_message(int socket, int type)
21 s_mc_message_t message;
24 while (send(socket, &message, sizeof(message), 0) == -1) {
33 int MC_protocol_hello(int socket)
36 if ((e = MC_protocol_send_simple_message(socket, MC_MESSAGE_HELLO)) != 0) {
37 XBT_ERROR("Could not send HELLO message: %s", strerror(e));
41 s_mc_message_t message;
42 message.type = MC_MESSAGE_NONE;
44 while (recv(socket, &message, sizeof(message), 0) == -1) {
48 XBT_ERROR("Could not receive HELLO message: %s", strerror(errno));
52 if (message.type != MC_MESSAGE_HELLO) {
53 XBT_ERROR("Did not receive suitable HELLO message. Who are you?");