refactor socket read/write with CocoaAsyncSocket