Q:

Objective C - HttpRequest with Daemon

i have created a daemon in Objective C that after search USB device, have to send an HttpRequest to an URL.
I have tried by Browser and the Host is reachable. 
For create a Daemon i have used Foundation framework and with this, i have tried to create an HTTP request with this simply way:
NSURLRequest *eventRequest = [NSURLRequest requestWithURL:_urlRequest cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];

self.theConnection=[[NSURLConnection alloc] initWithRequest:eventRequest delegate:self];

if (self.theConnection) {
    self.receivedData = [[NSMutableData data] retain];
} else {
    // Inform the user that the connection failed.
    NSLog(@"Connection Problem");
}

But in this case i have 2 problems:

The request was not send.
The Daemon ends and doesn't wait the response of HttpRequest.

How can i solve this problem?
Does exist another way to make an HTTP Request and get response?
regards.

A:

Using the normal way to send http message with the NSURLConnection Framework doesn't run the i have try the CoreFoundation.Framework to do that:
-(void)implementaZioneChiamata{

for (int i = 0; i < [_arrayOfSerial count]; i++) {

    CFStringRef urlFirst = CFSTR("http://192.168.30.9:88/virtualBadge.aspx?token=");
    CFStringRef token =(CFStringRef)_codicePWD;
    CFStringRef urlSecond = CFSTR("&serial=");
    CFStringRef serial = (CFStringRef) [_arrayOfSerial objectAtIndex:i];
    NSLog(@"URL: %@%@%@%@", urlFirst,token,urlSecond,serial);

    CFStringRef strs[4];

    strs[0] = urlFirst;
    strs[1] = token;
    strs[2] = urlSecond;
    strs[3] = serial;

    CFArrayRef urlArray = CFArrayCreate(kCFAllocatorDefault, (void*)strs, 4, &kCFTypeArrayCallBacks);

    CFStringRef urlCompleta = CFStringCreateByCombiningStrings(kCFAllocatorDefault, urlArray, CFSTR(""));
    NSLog(@"Url Completa: %@",urlCompleta);

    CFURLRef myURL = CFURLCreateWithString(kCFAllocatorDefault, urlCompleta, NULL);
    CFStringRef headerFieldName = CFSTR("host");
    CFStringRef headerFieldValue = CFSTR("192.168.30.9");

    CFStringRef requestMethod = CFSTR("GET");
    CFHTTPMessageRef myRequest =CFHTTPMessageCreateRequest(kCFAllocatorDefault, requestMethod, myURL,
                               kCFHTTPVersion1_1);
      CFHTTPMessageSetHeaderFieldValue(myRequest, headerFieldName, headerFieldValue);
       CFDataRef mySerializedRequest = CFHTTPMessageCopySerializedMessage(myRequest);

    NSString *messReq = [[NSString alloc] initWithData:(NSData*)mySerializedRequest encoding:NSASCIIStringEncoding];

    CFStream

    NSLog(@"Serialized Request: %@", messReq);

}

in the first part of code i create the URL. After this i Inizialize the CFHTTPMessageRef for create the HttpRequest.But now there is the problem:
Once i have the HttpMessage to send it I need to Create the CFStreamRef for send the message. Starting to the idea that i create the stream how i can send message? With CFStream API?
ok Guy Tnx all for Help after open the stream the request was Send adding de stream like this. 
CFReadStreamRef myReadStream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, myRequest);

CFReadStreamOpen(myReadStream);

Tnx all!!

