Clarify socket read/write logic