refactor: removed a piece of duplicate code from the stream-typed cosocket implementation.