hvolmer
unread,Jan 26, 2012, 7:09:04 PM1/26/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to CocoaAsyncSocket
I must prefix this by thanking everyone involved in creating
AsyncSocket over the years. It's been very handy!
I'm pretty hung up on adding GCD.. to an existing iOS project. I have
a tiny class that is responsible for managing each client
GCDAsyncSocket. It connects to a test server for me.
What happens: Compiles fine. The GCD client connects and then my app
immediately crashes in the iOS Sim.
If find it dies in: - (BOOL)connectWithAddress4: with [self
didConnect:aConnectIndex]; highlighted. I'm not very good at reading
these failures or I would provide more information...
I have even copied all of the code from the ConnectTest sample project
- no luck. The ConnectTest project fine by itself. I've even pointed
the ConnectTest project at my server and it works fine. I thought
that this might have something to do with ARC (I have set the -fno-
objc-arc flag on the GCDAsyncSocket file), so I converted the
ConnectTest project over to ARC, using XCode's handy tool, and it runs
fine also.
What should I look for? Is there some sort of trace I can provide
that might help? I've attached pretty much everything GCD.. related
below. Thanks.
-(void)connect
{
dispatch_queue_t mainQueue = dispatch_get_main_queue();
socket = [[GCDAsyncSocket alloc] initWithDelegate:self
delegateQueue:mainQueue];
NSString *host = @"localhost";
uint16_t port = 56789;
NSError *error = nil;
if (![socket connectToHost:host onPort:port error:&error])
{
NSLog(@"Oops");
}
}
/
**************************************************************************************/
#pragma mark Socket Delegate Methods
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString
*)host port:(UInt16)port
{
NSLog(@"Cool, I'm connected! That was easy.");
}
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
{
}
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data
withTag:(long)tag
{
NSString *response = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(@"In: %@", response);
}
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError
*)err
{
NSLog(@"SocketDidDisconnect");
}