Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inet_network does not exist on Windows, so replace htonl(inet_network…
…(c)) with inet_addr(c). Verified that it gives the same result with the code, 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(); } Compiled with mpicxx testinet.cxx -o testinet Output was cary@kara/.../~$ mpiexec -np 1 testinet myaddr1 = -285103936 myaddr2 = -285103936
- Loading branch information