refine socket message code