- /*
- for (cursor=0; cursor<XBT_MAX_CHANNEL; cursor++) {
- if (remote_hd->proc[cursor] == r_pid) {
- sockdata->to_chan = cursor;
- DEBUG2("Chan %d on %s is for my pal",
- cursor,res->peer_name);
-
- xbt_dynar_foreach(remote_hd->ports, cpt, pr) {
- if (sockdata->to_chan == pr.tochan) {
- if (pr.meas) {
- DEBUG0("Damn, it's for measurement");
- continue;
- }
-
- res->peer_port = pr.port;
- DEBUG1("Cool, it points to port %d", pr.port);
- break;
- } else {
- DEBUG2("Wrong port (tochan=%d, looking for %d)\n",
- pr.tochan,sockdata->to_chan);
- }
- }
- if (res->peer_port == -10) {
- sockdata->to_chan = -1;
- } else {
- break;
- }
- }
+
+ /* search for a free port on the host */
+ local_hd = (gras_hostdata_t *)SIMIX_host_get_data(SIMIX_host_self());
+ for (i=1;i<65536;i++) {
+ if (local_hd->cond_port[i] == NULL)
+ break;