Refactor to reduce the coupling between the parser and the socket I/O object.