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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:31:19+00:00 2026-05-31T09:31:19+00:00

After I have read the answer for this question I have found that using

  • 0

After I have read the answer for this question I have found that using reachabilityWithHostName does not work with a URL such as this one: mySite.com/service.asmx , is there anyway to check reachability against this URL using reachabilityWithHostName or any reachability class method ?

thanks so much in advance.

  • 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-05-31T09:31:20+00:00Added an answer on May 31, 2026 at 9:31 am

    The Reachability class and -reachabilityWithHostname: is designed to be a quick, fail-fast mechanism to determine whether you have basic network connectivity to the host. If you need to verify that a particular URL can be downloaded, you need to be looking at using NSURLConnection to retrieve the contents of the URL in order to verify that it is truly available.

    Depending on whether you need to do this in the foreground or background, you can either use the simple-but-blocking:

    + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error
    

    or you can use the more complicated method of creating an NSURLConnection object, setting up a delegate to receive responses and wait for those responses to come in.

    For the simple case:

     NSURL *myURL = [NSURL URLWithString: @"http://example.com/service.asmx"];
     NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: myURL];
     [request setHTTPMethod: @"HEAD"];
     NSURLResponse *response;
     NSError *error;
     NSData *myData = [NSURLConnection sendSynchronousRequest: request returningResponse: &response error: &error];
    

    If you receive back a non-nil myData, you’ve got some kind of connectivity. response and error will tell you what the server responded to you (in the case of response and if you received a non-nil myData) or what kind of error occurred, in the case of a nil myData.

    For the non-trivial case, you can get good guidance from Apple’s Using NSURLConnection.

    If you don’t want to stall your foreground process, you can do this two different ways. The above documentation will provide information on how to implement the delegate, etc. However, a simpler implementation would be to use GCD to send the Synchronous request on a background thread, and then message yourself on the main thread when you are done.

    Something like this:

     NSURL *myURL = [NSURL URLWithString: @"http://example.com/service.asmx"];
     NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: myURL];
     [request setHTTPMethod: @"HEAD"];
     dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_BACKGROUND, NULL), ^{
          NSURLResponse *response;
          NSError *error;
          NSData *myData = [NSURLConnection sendSynchronousRequest: request returningResponse: &response error: &error];
          BOOL reachable;
    
          if (myData) {
                // we are probably reachable, check the response
                reachable=YES;
          } else {
                // we are probably not reachable, check the error:
                reachable=NO;
          }
    
          // now call ourselves back on the main thread
          dispatch_async( dispatch_get_main_queue(), ^{
                [self setReachability: reachable];
          });
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using stackoverflow for a question, I have read a
After repeated searching I have not found an elegant solution to this issue: how
I have (after quite a bit of work) a web test that will upload
I have been working on a quick WinForms program. I found this SO question
This question is a follow-up question to my previous one that can be found
I have been looking all over the Internet for an answer to this question
This is another question about well disposing objects from .NET. After having read a
Does anybody know how to find the number of rows affected AFTER I have
Using String.Format how can i ensure all numbers have commas after every 3 digits
I didn’t found short form for this question as subject… Is it possible to

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.