#include #include #ifdef _WIN32 #include #else #include #include #endif int main(int argc, char** argv) { MPI_Init(&argc, &argv); char hostname[MPI_MAX_PROCESSOR_NAME]; int len; MPI_Get_processor_name(hostname,&len); struct hostent * host = gethostbyname(hostname); int myaddr1 = (int) inet_addr(inet_ntoa(*(struct in_addr *)host->h_addr)); int myaddr2 = (int) htonl(inet_network(inet_ntoa(*(struct in_addr *)host->h_addr))); std::cout << "myaddr1 = " << myaddr1 << std::endl; std::cout << "myaddr2 = " << myaddr2 << std::endl; MPI_Finalize(); }