The mode is only set if it wasn't masked, i.e., the data wasn't finished reading yet. You don't need the ```if (recvsize-b)``` check then.