refine code for bug #217, use recv thread to set the timeout.