Hi there
I've recently been exploring the Network module and I created a simple client/server architecture that I'm hoping to implement in another project. The basic design intention was this:
1. Client Inputs To Computer
2. Input Packet Is Sent To Server
3. Server Receives Input Packet
4. Server Prints Packet Contents
5. Repeat
Fairly straightforward. I'm using UDP currently, though I tried switching to TCP and experienced the same issue I describe below. I've checked and triple checked, and yes, my sockets are properly bound and sending/receiving to/from the proper ip's and ports. There is no problem with the connection.
What the problem
is is the fact that the server always prints out the packets one iteration after it is supposed to. For example, my expected output, and the output I receive when I set all sockets to block, is this:
However, I don't want the sockets to block - my program should move on if no input is waiting to be received at a socket. So I set the sockets to non-blocking, and with the exact same set of inputs, my new output is this:
I've gone over my code many times, and the blocking state is definitely the cause. I don't understand why changing the blocking would cause such a malfunction. Could anyone enlighten me?
Thanks in advance!