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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:07:02+00:00 2026-06-04T06:07:02+00:00

We use a PHP server and an iOS app. I use NSURLConnection to send

  • 0

We use a PHP server and an iOS app.

I use NSURLConnection to send a message to the server. If server is unavailable, e.g. the address is incorrect then we wait for an error after 60–90 secs. This is a long time.

How do I decrease this time? Is there any quick function to check for server availability?

If I first call

[request setTimeoutInterval:10];
[request setHTTPBody:[message data]];

when I check [request timeoutInterval] it is still 240, not 10. So interesting..

If I add a setTimeoutInterval: call before the connection is created like so:

[request setTimeoutInterval:10];
connection = [[NSURLConnection alloc] initWithRequest: request delegate: self];

The request still returns after a long time.

  • 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-04T06:07:04+00:00Added an answer on June 4, 2026 at 6:07 am

    Yeah, timeouts don’t quite work like you would expect. One solution is to set up a timer that cancels the connection after your desired interval has elapsed. I did this in my ReallyRandom class, and it seems to do the trick.

    It looks something like this:

    connection = [[NSURLConnection alloc] initWithRequest: request delegate: self startImmediately:NO];
    
    timer = [NSTimer scheduledTimerWithTimeInterval:10
                                         target:self
                                       selector:@selector(onTimeExpired)
                                       userInfo:nil
                                        repeats:NO];
    
    [connection start];
    
    
    // When time expires, cancel the connection
    -(void)onTimeExpired
    {
        [self.connection cancel];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Sir i want send list of data to php server i use following
I'm trying to send email in windows server using PHP. When I use php
i have a rhel 4 server and use php as a server side scripting
I need to use PHP to connect to a URL via a proxy server.
I like CKEditor and my server uses PHP. I want to use CKEditor to
I am trying to plan out a few iOS/server apps for internal use. On
All the time, I use PHP on server side to generate HTML/XHTML directly or
Is there a way to use the Google Translate API with PHP (server-side)?
In PHP 5.3.0+ (on my local server) I have intl library installed. I use
Is it wrong to use PHP as a server side language? For functions such

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.