+ /* get a free socket for the receiving part of the listener, taking care that it does not get saved as "myport" number */
+ my_port =
+ ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->myport;
+ arg->wakeup_sock_listener_side =
+ gras_socket_server_range(5000, 6000, -1, 0);
+ ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->myport =
+ my_port;
+ /* Connect the other part of the socket */
+ arg->wakeup_sock_master_side =
+ gras_socket_client(gras_os_myname(),
+ gras_socket_my_port(arg->wakeup_sock_listener_side));
+
+ /* declare the message used to awake the listener from the master */
+ gras_msgtype_declare("_wakeup_listener", gras_datadesc_by_name("char"));
+
+ /* actually start the thread */
+ arg->listener = xbt_thread_create("listener", listener_function, arg,1/*joinable*/);
+ gras_os_sleep(0); /* TODO: useless? give the listener a chance to initialize even if the main is empty and we cancel it right afterward */