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 8559151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:58:28+00:00 2026-06-11T15:58:28+00:00

I am currently building an App using CocoaAsyncSocket. I connect to a TCP server

  • 0

I am currently building an App using CocoaAsyncSocket. I connect to a TCP server and read/write some data.

I create the socket using

self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];

When data is received, I use FMDB to save it into a database. Everything works fine, until I send the App to Background (using Homebutton), and then resuming to it. The UI is frozen and not responsive, the Debugger shows, that it is waiting at semaphore_wait_trap.

  • 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-11T15:58:29+00:00Added an answer on June 11, 2026 at 3:58 pm

    Don’t use the main queue as an argument to the delegateQueue parameter. Use one of the global concurrent queues or a serial/parallel queue you create yourself.

    Update: I just looked at the implementation for GCDAsyncSocket and now realize that the delegate queue and methods are fired async to the actual read/write operations, which happen on an internal queue, so my suggestion was either irrelevant (depending on what you’re actually doing in the completion methods) or, at the very least, not pertinent to the problem you’re having. I think what’s happening is that the internal socket(s) are being closed, as per the iOS App Programming Guide. To wit:

    • Be prepared to handle connection failures in your network-based
      sockets. The system may tear down socket connections while your app
      is suspended for any number of reasons. As long as your socket-based
      code is prepared for other types of network failures, such as a lost
      signal or network transition, this should not lead to any unusual
      problems. When your app resumes, if it encounters a failure upon
      using a socket, simply reestablish the connection.

    The GCDAsyncSocket class you’re using has some methods which seem to be aimed at dealing with this, such as -autoDisconnectOnClosedReadStream, and I think you just need to add some code to handle the disconnection / connection re-establishment case.

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

Sidebar

Related Questions

I am currently building a little Apache-Mina Server app. I am using Maven to
Some background I'm currently building a predominantly classic web app (rather than a single
I am currently building a Flex 4 web app using PHP as my backend.
I'm building an app that needs to hide consecutive rows. Currently I'm using this:
I am currently building a WP7 app using the MVVMLight framework. I would like
Currently I am building an app using phonegap for the Android and iOS systems.
I am currently building an web app using mostly PHP and JavaScript. What is
I am currently building an Iphone app that is using storyboards. I know how
I'm building a simple mvc3 app using jqgrid. My form currently calls a function
I´m currently building a web radio streaming app using the BackgroundAudioPlayer. The problem is

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.