unrolled tcp nonblocking function