#include "MPI2Connector.hxx"
#include <iostream>
+#include <string.h>
MPI2Connector::MPI2Connector()
{
{
/* rank 0 try to be a server. If service is already published, try to be a cient */
MPI_Open_port(MPI_INFO_NULL, port_name);
- if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS )
+ if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS )
+ {
+ std::cerr << "[" << _num_proc << "] I get the connection with " << service << " at " << port_name_clt << std::endl;
+ MPI_Close_port( port_name );
+ }
+ else if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS )
{
_srv = true;
_port_name = port_name;