Fix socket and tcp issue