improve and simplify the code for connected unix socket.