in reply to make my code non block
Which OS are these meant to run on?
See Re: How to do simultaneous reads and writes to/from a socket?.