Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: [OMPI users] Client/Server test
From: Alberto Giannetti (albertogiannetti_at_[hidden])
Date: 2008-04-26 00:31:54

I want to connect two MPI programs through the MPI_Comm_connect/
MPI_Comm_Accept API.
This is my server app:

int main(int argc, char* argv[])
   int rank, count;
   int i;
   float data[100];
   char myport[MPI_MAX_PORT_NAME];
   MPI_Status status;
   MPI_Comm intercomm;

   MPI_Init(&argc, &argv);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   printf("Processor %d (%d, Receiver) initialized\n", rank, getpid());

   MPI_Open_port(MPI_INFO_NULL, myport);
   printf("Opened port %s\n", myport);

   printf("Waiting for connections on %s...\n", myport);
   MPI_Comm_accept(myport, MPI_INFO_NULL, 0, MPI_COMM_SELF, &intercomm);
   printf("New connection on port %s\n", myport);

   printf("Processor %d waiting for data from new intercomm...\n",
intercomm, &status);
   MPI_Get_count(&status, MPI_FLOAT, &count);
   printf("Processor %d got %d elements: %f, %f, %f...\n", rank,
count, data[0], data[1], data[2]);


And my client program:

int main(int argc, char* argv[])
   int rank, i;
   float data[100];
   char myport[MPI_MAX_PORT_NAME];
   MPI_Comm intercomm;

   MPI_Init(&argc, &argv);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   printf("Processor %d (%d, Sender) initialized\n", rank, getpid());

   if( argc < 2 ) {
     fprintf(stderr, "Require server port name\n");

   for( i = 0; i < 100; i++ )
     data[i] = i;

   strcpy(myport, argv[1]);
   printf("Processor %d connecting to '%s'\n", rank, myport);
   MPI_Comm_connect(myport, MPI_INFO_NULL, 0, MPI_COMM_SELF,

   printf("Processor %d sending data through intercomm...\n", rank);
   MPI_Send(data, 100, MPI_FLOAT, 0, 55, intercomm);
   printf("Processor %d data sent!\n", rank);


I run the server program:

mpirun -np 2 app2
Processor 0 (7916, Receiver) initialized
Processor 1 (7918, Receiver) initialized
Opened port 0.1.0:2000
Waiting for connections on 0.1.0:2000...
Opened port 0.1.1:2001
Waiting for connections on 0.1.1:2001...

Then the client:

mpirun -np 1 app1 0.1.0:2000
Processor 0 (7933, Sender) initialized
Processor 0 connecting to '0.1.0:2000'
[alberto-giannettis-computer.local:07933] [0,1,0] ORTE_ERROR_LOG: Not
found in file /tmp/buildpackage-3432/openmpi-1.2.4/orte/dss/
dss_unpack.c at line 209
[alberto-giannettis-computer.local:07933] [0,1,0] ORTE_ERROR_LOG: Not
found in file /tmp/buildpackage-3432/openmpi-1.2.4/ompi/communicator/
comm_dyn.c at line 186
[alberto-giannettis-computer.local:07933] *** An error occurred in
[alberto-giannettis-computer.local:07933] *** on communicator
[alberto-giannettis-computer.local:07933] *** MPI_ERR_INTERN:
internal error
[alberto-giannettis-computer.local:07933] *** MPI_ERRORS_ARE_FATAL

Why do I have an internal error? If I try to connect to 0.1.1:2001
from the client the program hangs.