for bug #237, thread donot sleep when timeout is 0.
for bug #241, use heap to alloc the socket buffer.