reuse socket and add thread communication