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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:12:44+00:00 2026-06-08T18:12:44+00:00

Currently when i open an NSInputStream (for example) I can set it up to

  • 0

Currently when i open an NSInputStream (for example) I can set it up to get an event indicating that it has opened completely. But if it fails, there is no event at all. I never get told that the opening failed to complete. I can poll while it is attempting to open, but then I have to tie up a thread for potentially a lengthy period of time.

What I want to do is write efficient code that waits for either the stream to open or fail to open. Is there any such way using NSStream et al?

I also thought of creating an event that I could wait on for a set period of time. If the connection succeeded, the event would signal and pop me out of my wait state. If the timeout occurred, I could test the status and see if it failed or go back into the wait state again. But of course this is plan B, not eloquent and not efficient. And looking through the CocoaTouch documentation doesn’t make clear at all how to create such a signal that I can wait on with a timeout.

Any help would be appreciated.

  • 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-08T18:12:45+00:00Added an answer on June 8, 2026 at 6:12 pm

    There is an event that occurs when a NSStream fails to open: NSStreamEventErrorOccurred. Perhaps the problem you are encountering is that the TCP/IP timeout can be very long. So if a connection to a host is going to fail it may be 30 seconds before you get this event.

    You could start an NSTimer at the same time that open the stream for some shorter interval, but then you run into the problem of what that interval should be?

    It is often better to leave the option to cancel the connection in the hands of the user, unless the TCP/IP timeout occurs.

    What I have done in a number of projects is popped a custom modal view with an activity indicator and a cancel button after about 1 second. Many connections on local networks will complete before this time and the user will not be bothered by the popup. For slower connections this allows the user to decide how long they are willing to wait. You can even update the message in the modal view after some longer period of time to say that it is taking longer to connect than usual so they know the program is aware that they are waiting!

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

Sidebar

Related Questions

How can I get the exact height and width of the currently open browser
In Linux, how can I get a list of files currently open in program
All I need is to get the list of currently open documents in the
Currently when I open a file with my program I can select files on
Currently In my embedded linux I can not open multiple ALSA sound stream. What
I currently have a series links that open menus containing dropdowns and input textboxes
currently i using this code in phonegap application var xmlhttp = new XMLHttpRequest(); xmlhttp.open(GET,http://192.168.1.19:8080/searchMobile?categoryRequest=true,
Every time I open a page I want to get the currently active project
Is there any way to get the path of documents currently open in Microsoft
I want to get the file name of the currently open tab in the

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.