开发者

Problems receiving UPD Package with AsyncUdpSocket on Iphone SDK

I have a small app to test sockethandling on the iPhone and I use the AsyncSocket/AsyncUdpSocket lib.

Opening the socket and sending is not a problem but receiving is.

//Called when state is received
- (BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port
{
    NSLog(@"Incoming data");

开发者_StackOverflow    [sock receiveWithTimeout:-1 tag:0];
    return YES;
}

As I said, I do not get anything, but the question is, does the method only gets called when the upd package is complete ? How does the package needs to end? Zero Byte?

Thanks


You should call the receive method (I think with a positive timeout) after sending out your packet. When the response is received the delegate method will be called and then you can process the received data.

-raliz

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜