example/netcat.c: detect EOF of stdin and connection