Note that there are some explanatory texts on larger screens.

plurals
  1. POClient connects to server but server does not think client has connected in C++
    primarykey
    data
    text
    <p>I have a C++ program, using mpi, that follows a typical client server model. Each mpi instance of the client connects to a corresponding mpi instance of the server. This has worked relatively well until I have had to do some testing with added latency (1 second of added latency to be precise).</p> <p>Problem: Sometimes one of the server processes do not think the client has connected but the client thinks it has connected. i.e. After using gdb, the server is waiting at accept() but the client has continued on past connect(). Thus, it appears the client thinks it has connected when the server does not think it has connected. </p> <p>My best guess is that I need to set an sock-option somewhere, however talking to fellow programmers and googling has not yielded any helpful results. </p> <p>EDIT: There are two sets of MPI processes (so two different calls to mpirun), the accept() and connect() calls are for the sockets, which are between the two sets of MPI processes. It is openmpi. </p> <p>The code (from someone else's code, actually) [reduced]:</p> <p>Client (connect code): (m_socket is the actual socket)</p> <pre><code> if (-1 == m_socket) { perror("cannot create socket"); exit(EXIT_FAILURE); } memset(&amp;addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); res = inet_pton(AF_INET, host_ip, &amp;addr.sin_addr); if (0 &gt; res) { perror("error: first parameter is not a valid address family"); close(m_socket); exit(EXIT_FAILURE); } else if (0 == res) { perror("error: second parameter does not contain valid IP address"); close(m_socket); exit(EXIT_FAILURE); } //backoff for (int sec = 1; sec &lt; 20000; sec++ ) { int ret; if (0 == (ret = connect(m_socket, (struct sockaddr *)&amp;addr, sizeof(addr)))) { return; } sleep(1); close(m_socket); m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); } perror("connect failed"); close(m_socket); exit(EXIT_FAILURE); </code></pre> <p>Server: (m_socket is the actual socket)</p> <pre><code> int socket = ::accept(m_socket, NULL, NULL); if(socket &lt; 0) { fprintf(stderr, "accept() failed: %s\n", strerror(errno)); close(m_socket); exit(EXIT_FAILURE); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload