Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Feb 14, 2013, 07:04 PM   #1
macrumors newbie
Join Date: Feb 2013
GCDAsyncSockets works on some, not all iPhones


I have the code posted below (mostly cut right out of an example on GitHub) working well on an Iphone 3 with 5.0, and an iPod iTouch running 6.0. But it fails to write on another iPhone 3 with 6.0. Are there some settings I need to enable under "Settings" to enable sockets? The non writing phone can reach the host on its Safari browser so it doesn't seem to be a connectivity issue. All the rest of the software in question works on all phones.

here's the code that works on 2 devices and not on the third.
//next is attempt to implement GCDAsyncSockets 2/4/2014 build 0.9.589
    GCDAsyncSocket *socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    NSError *err = nil;
    if (![socket connectToHost:ipAddress.text onPort:9100 error:&err]) // Asynchronous!
        // If there was an error, it's likely something like "already connected" or "no delegate set"
        NSLog(@"I goofed: %@", err);
    outputData = [[NSData alloc] initWithData:[response dataUsingEncoding:NSASCIIStringEncoding]];

    [socket writeData:outputData withTimeout:-1 tag:1];
Thx in Advance

Last edited by maflynn; Feb 15, 2013 at 05:29 AM. Reason: Code tags added
electricfreddy is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 09:17 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC