asyncsocket Write Issue

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-05-30T23:52:33Z Indexed on 2010/05/31 0:02 UTC
Read the original article Hit count: 384

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa