in reply to Re^3: golf challenge: one-liner netcat clone
in thread golf challenge: one-liner netcat clone

If you try reading from the socket, your program will become permanently blocked.

The select call takes care of that. The program only reads when there is data available and the buffer is not full.

Replies are listed 'Best First'.
Re^5: golf challenge: one-liner netcat clone
by ikegami (Patriarch) on Dec 11, 2011 at 09:32 UTC

    Yes, you're right, the select (or more precisely, the if vec) takes care of that.

    So yes, you don't need to make the *read* handle non-blocking because of that check.

    You do need to continue making the *write* handles non-blocking because you don't have a similar check around syswrite. (Note that the similar check for write handles involves checking how many bytes you can write without blocking.)

    Sorry, I got confused by the lack of symmetry between your reading and writing code.