I'm running a client and server on the same machine using a loopback address for learning purposes yet my "server" code seems to fly back listen() and then hangs on my connect(). Does listen() need to be in an endless loop to keep receiving connections?
How would I determine a connection is made/in the queue if listen() returns 0 even when I haven't made a connection yet?
I have an accept() call following but the code hangs on that spot. I have debug statements right before and after and it never gets past the accept().
On the other end my client code seems to connect() just fine (doesn't throw an error) and appears to write and complete even though the server code never gets the connection.
The listen
function defines the backlog. Only need to call this once.
Then use accept
to receive an incoming connection. Best to deal with this promptly and go around again for another accept
.