title: didConnectToHost isn't getting called
body: <p>I've made a client with a class named "NetClass" using <code>GCDAsyncSocket</code> and importing  <code>CGDAsyncSocket.h</code>. 
  Than in my <code>LoginViewController</code> I've called my net class function to connect to the server.  </p>
  
  <p>On the server side I see that client is connected, but on the client side <code>didConnectToHost</code> doesn't get called.</p>
  
  <p>My <code>NetClass</code> call in <code>LoginViewController</code>:</p>
  
  <pre><code>NetClass *nc = [[NetClass alloc] init];
      [nc ReceiveData:ip login:login password:md5 ];
  </code></pre>
  
  <p>And my <code>NetClass</code> functions:</p>
  
  <pre><code>- (BOOL)ReceiveData:(NSString *)ip login:(NSString*)login password:(NSString*)password
  {
      dispatch_queue_t mainQueue = dispatch_get_main_queue();
      asyncSocket = [[GCDAsyncSocket alloc]initWithDelegate:self delegateQueue:mainQueue];
  
      NSError *error = nil;
      uint16_t port = 2012;
      if (![asyncSocket connectToHost:ip onPort:port error:&amp;error])
      {
          NSLog(@"Error connecting: %@", error);
          return NO;
      }
      else
      {
          NSLog(@"%@",asyncSocket.connectedHost);
          NSData *data = [[NSString stringWithFormat:@"&lt;MOBIL&gt;&lt;refreshall&gt;TRUE&lt;/refreshall&gt;&lt;user&gt;%@&lt;/user&gt;&lt;password&gt;%@&lt;/password&gt;",@"tst",@"tsts"] dataUsingEncoding:NSASCIIStringEncoding];
          NSData *enddata = [[NSString stringWithFormat:@"&lt;/ddodata"] dataUsingEncoding:NSASCIIStringEncoding];
          [asyncSocket writeData:data withTimeout:-1 tag:1];
          [asyncSocket readDataToData:enddata  withTimeout:-1 maxLength:-1 tag:1];
          [asyncSocket disconnect];
          return YES;
      }
  
  
  }
  - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port
  {
      NSLog(@"%@ %@",@"CONNECTED TO HOST",host);
  }
  
  - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err
  {
      NSLog(@"socketDidDiscoffffnnect:%p withError: %@", sock, err);
  }
  </code></pre>
  
  <p>But at the same time function socketDidDisconnect is getting called</p>
  
  <p>NSLog output :</p>
  
  <pre><code>  2012-08-25 14:16:46.312 TacticalView[34981:f803] (null)
  2012-08-25 14:16:46.313 TacticalView[34981:f803] socketDidDiscoffffnnect:0x88024d0 withError: (null)
  </code></pre>
  
  <p>I see that asyncSocket not connecting when change ReceiveData like this:</p>
  
  <pre><code> if (![asyncSocket connectToHost:ip onPort:port error:&amp;error])
      {
          NSLog(@"Error connecting: %@", error);
          return NO;
      }
      else
      {
          if ([asyncSocket isConnected])
          {
  
          NSData *data = [[NSString stringWithFormat:@"&lt;MOBIL&gt;&lt;refreshall&gt;TRUE&lt;/refreshall&gt;&lt;user&gt;%@&lt;/user&gt;&lt;password&gt;%@&lt;/password&gt;",@"tst",@"tsts"] dataUsingEncoding:NSASCIIStringEncoding];
  
          NSData *enddata = [[NSString stringWithFormat:@"&lt;/ddodata"] dataUsingEncoding:NSASCIIStringEncoding];
  
          [asyncSocket writeData:data withTimeout:-1 tag:1];
          [asyncSocket readDataToData:enddata  withTimeout:-1 maxLength:-1 tag:1];
          [asyncSocket disconnect];
          }
          return YES;
      }
  </code></pre>
  
  <p>And if i make socket in my LoginViewController the didConnectToHost method is calling perfectly/ What's wrong&amp; Why i can't use this method in my NetClass? </p>