The call is returning immediately because you've set the socket to NON-BLOCKING. Using a timeout with a non-blocking socket makes no sense. If you want timed reads/writes, just configure the timeouts...