title: GCDAsyncSocket not connecting or giving me error to know it failed
body: <p>I am trying to use the <code>GCDAsyncSocket</code> class to connect to a device but am having trouble. It seems to fail to inform me if it connects, but also fails to inform me it failed to connect.</p>
  
  <p>Here is my .h file</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import "GCDAsyncSocket.h"
  
  @interface SocketTestClass : NSObject &lt;GCDAsyncSocketDelegate&gt;
  {
      GCDAsyncSocket* socket;
  }
  
  @end
  </code></pre>
  
  <p>and here is my .m file</p>
  
  <pre><code>@implementation SocketTestClass
  
  - (void)dealloc
  {
      [self disconnect];
  }
  
  - (void)connect
  {
      NSLog(@"Ready to create socket");
  
      socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
  
      NSError* error = Nil;
      if (![socket connectToHost:@"192.168.1.200" onPort:80 withTimeout:10 error:&amp;error])
      {
          NSLog(@"Failed to create socket");
      }
  }
  
  - (void)disconnect
  {
      if ([socket isConnected])
      {
          [socket disconnect];
      }
  }
  
  - (void)socket:(GCDAsyncSocket *)sock
  didAcceptNewSocket:(GCDAsyncSocket *)newSocket
  {
      NSLog(@"Socket did accept new socket");
  }
  
  - (void)socket:(GCDAsyncSocket *)sock
  didConnectToHost:(NSString *)host
            port:(uint16_t)port
  {
      NSLog(@"Socket did connect to host on port");
  }
  
  - (void)socket:(GCDAsyncSocket *)sock
     didReadData:(NSData *)data
         withTag:(long)tag
  {
      NSLog(@"Socket did read data with tag");
  }
  
  - (void)socket:(GCDAsyncSocket *)sock
  didReadPartialDataOfLength:(NSUInteger)partialLength
             tag:(long)tag
  {
      NSLog(@"Socket did read partial data of length");
  }
  
  - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
  {
      NSLog(@"Socket did write data with tag");
  }
  
  - (void)socket:(GCDAsyncSocket *)sock
  didWritePartialDataOfLength:(NSUInteger)partialLength
             tag:(long)tag
  {
      NSLog(@"Socket did write partial data of length");
  }
  
  - (void)socketDidCloseReadStream:(GCDAsyncSocket *)sock
  {
      NSLog(@"Socket did close read stream");
  }
  
  - (void)socketDidDisconnect:(GCDAsyncSocket *)sock
                    withError:(NSError *)err
  {
      NSLog(@"Socket did disconnect with error");
  }
  
  - (void)socketDidSecure:(GCDAsyncSocket *)sock
  {
      NSLog(@"Socket did secure");
  }
  
  @end
  </code></pre>
  
  <p>From my view controller I call the connect method of this class but the only thing that prints out to the console is:</p>
  
  <pre><code>Ready to create socket
  </code></pre>
  
  <p>Note: I have implemented all delegates for <code>GCDAsyncSocket</code> and have all writing to the console via <code>NSLog</code>.</p>
  
  <p>Any idea as to why I do not get the message "Socket did connect to host on port" or the message "Socket did disconnect with error"?</p>