Google for "non-blocking socket". You should find a lot of examples about it. I had the same doubt.

(=