Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:06:13+00:00 2026-06-05T12:06:13+00:00

I have separated my networking code in a separate class IBStore. The code is

  • 0

I have separated my networking code in a separate class IBStore. The code is very straightforward and based on the samples provided:

#import <UIKit/UIKit.h>
#import "GCDAsyncSocket.h"

@interface IBStore : UIViewController
{
    GCDAsyncSocket *socket;
}
- (void)connect;
- (void)socket:(GCDAsyncSocket *)sender didConnectToHost:(NSString *)host port:(UInt16)port;
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag;
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag;
@end

and:

#import "IBStore.h"

@interface IBStore ()
@end


@implementation IBStore

- (void)connect
{
    socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];    

    NSError *err = nil;
    if (![socket connectToHost:@"127.0.0.1" onPort:80 error:&err]) // Asynchronous!
    {
        // If there was an error, it's likely something like "already connected" or "no delegate set"
        NSLog(@"Connection error: %@", err);
    }
}

This is how IBStore is instantiated from the main view controller:

- (IBAction)connect:(id)sender {
    IBStore *client = [[IBStore alloc]init];
    [client connect];
}

Unfortunately, instead of executing didConnectToHost, the app crashes (hangs) in GCDAsyncSocket.m when it is executing socket4FD = socket(AF_INET, SOCK_STREAM, 0);

Any ideas on why this happens would be highly appreciated. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:06:14+00:00Added an answer on June 5, 2026 at 12:06 pm

    My error was declaring and instantiating the IBStore class in the connect method. Now, I have declared IBStore *client as a instance variable and it works perfect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a txt file with columns separated by tabs and based on that
I have separated my Global resource files to a different class library in my
I have separated my resource file to another class library and i am using
I'm very new to CI. :) In my project, I have separated the page
I have 5-6 jobs to be done by cron, and i have separated php
I have semicolon-separated .dat file and I want to read that file and store
I have comma-separated values. I need a query to insert into SQL Server 2008
I want to merge two branches that have been separated for a while and
I've just finished merging two branches that have been separated for a long time,
I have a tab-separated data file with a little over 2 million lines and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.