asyncsocket写问题

时间:2010-05-30 23:52:33

标签: iphone cocoa asyncsocket

我正在尝试使用asyncsocket将我的iPhone上的服务器应用程序中的GPS数据传送到我的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方法。谁能解释一下呢?

谢谢!

詹姆斯

0 个答案:

没有答案