Register messages before opening the sockets, to avoid to receive
unknown messages.
XBT_INFO("Launch client (server on %s:%d)", host, port);
XBT_INFO("Launch client (server on %s:%d)", host, port);
- /* 3. Create a socket to speak to the server */
+ /* 3. Register the messages (before use) */
+ mmrpc_register_messages();
+
+ /* 4. Create a socket to speak to the server */
while (!connected) {
TRY {
toserver = gras_socket_client(host, port);
while (!connected) {
TRY {
toserver = gras_socket_client(host, port);
}
XBT_INFO("Connected to %s:%d.", host, port);
}
XBT_INFO("Connected to %s:%d.", host, port);
-
- /* 4. Register the messages (before use) */
- mmrpc_register_messages();
-
/* 5. Keep the user informed of what's going on */
XBT_INFO(">>>>>>>> Connected to server which is on %s:%d <<<<<<<<",
gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
/* 5. Keep the user informed of what's going on */
XBT_INFO(">>>>>>>> Connected to server which is on %s:%d <<<<<<<<",
gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
- /* 3. Create my master socket */
+ /* 3. Register the known messages and payloads. */
+ mmrpc_register_messages();
+
+ /* 4. Register my callback */
+ gras_cb_register("request", &server_cb_request_handler);
+
+ /* 5. Create my master socket */
XBT_INFO("Launch server (port=%d)", port);
TRY {
sock = gras_socket_server(port);
XBT_INFO("Launch server (port=%d)", port);
TRY {
sock = gras_socket_server(port);
RETHROWF("Unable to establish a server socket: %s");
}
RETHROWF("Unable to establish a server socket: %s");
}
- /* 4. Register the known messages and payloads. */
- mmrpc_register_messages();
-
- /* 5. Register my callback */
- gras_cb_register("request", &server_cb_request_handler);
-
/* 6. Wait up to 10 minutes for an incomming message to handle */
gras_msg_handle(600.0);
/* 6. Wait up to 10 minutes for an incomming message to handle */
gras_msg_handle(600.0);