asyncsocket写入问题
我正在尝试使用 asyncsocket 将 GPS 数据从 iPhone 上的服务器应用程序传输到 MacBook 上的客户端应用程序。两个设备连接没有任何问题,并且当在 asyncsocket 的 didConnectToHost 方法中将第一个数据从 iPhone 发送到笔记本电脑时,数据发送没有中断。然而,当我随后尝试从 locationManager 方法向笔记本电脑写入附加数据时,没有写入任何数据。这是代码:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
lat = [NSNumber numberWithFloat:newLocation.coordinate.latitude];
[lat retain];
NSLog(@"lat: %1.0f", [lat floatValue]);
NSString *msg = [NSString stringWithFormat:@"%1.0f", [lat floatValue]];
NSData *msgData = [msg dataUsingEncoding:NSUTF8StringEncoding];
[listenSocket writeData:msgData withTimeout:-1 tag:0];
}
listensocket 是我的 ASyncSocket 实例。我知道没有数据被发送,因为在初始成功传输后,没有调用 didWriteDataWithTag 方法。谁能解释一下吗?
谢谢!
詹姆斯
I am attempting to use asyncsocket to communicate GPS data from a server app on my iPhone to a client app on my macbook. The two devices connect without any problems, and when the first data is sent from the iPhone to the laptop in asyncsocket's didConnectToHost method, the data is sent without hiccup. When I subsequently try to write additional data to the laptop from the locationManager method, however, no data is written. Here is the code:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
lat = [NSNumber numberWithFloat:newLocation.coordinate.latitude];
[lat retain];
NSLog(@"lat: %1.0f", [lat floatValue]);
NSString *msg = [NSString stringWithFormat:@"%1.0f", [lat floatValue]];
NSData *msgData = [msg dataUsingEncoding:NSUTF8StringEncoding];
[listenSocket writeData:msgData withTimeout:-1 tag:0];
}
listensocket is my instance of ASyncSocket. I know that no data is being sent because after the initial successful transfer, the didWriteDataWithTag method is not called. Can anyone explain this?
Thanks!
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论