CocoaAsyncSocket/GCDAsyncSocket が使用されている tcp 経由で netty サーバーに protobuf メッセージを送信する必要がある小さなアプリを作成しています。
これを行うには、次のコードを使用します。
Message_LoginMessageRequest_Builder *msg_tmp_login_build=[Message_LoginMessageRequest builder];
[msg_tmp_login_build setPhoneNumber:input_phone.text];
[msg_tmp_login_build setEmail:input_email.text];
[msg_tmp_login_build setPassword:input_password.text];
Message_Builder *msg_tmp_build=[Message builder];
[msg_tmp_build setType:Message_MessageTypeLoginReq];
[msg_tmp_build setLoginRequest:msg_tmp_login_build.build];
// send the message to the socket: we need to code the stream first
Message *msg=[msg_tmp_build build];
NSMutableData *msg_data=[[NSMutableData alloc] initWithCapacity:[[msg data] length]];
PBCodedOutputStream *coded_output_stream=[PBCodedOutputStream streamWithData:msg_data];
[msg writeToCodedOutputStream:coded_output_stream];
[socket writeData:msg_data withTimeout:-1 tag:Message_MessageTypeLoginReq];
ただし、コードは writeToCodedOutputStream で常に「領域不足」エラーを受け取りました。詳細なトレース情報は、writeToCodedOutputStream/writeEnum/writeTag/writeRawVariant32/writeRawByte/flush です。
何か助けはありますか?ありがとう!