Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

multinode

macrumors regular
Original poster
Feb 4, 2011
150
0
In CocoaEcho (see the link below) its server's Main.m advertises the service @"_cocoaecho._tcp." and its client looks for that service to then make a connection. What is the form of an http service for a web server please? I'd like to substitute that service in CocoaEcho's Main.m on my MacBook so that my IPad's Safari can see it. I think that that would make my MacBook be a WiFi server.

http://developer.apple.com/library/mac/#samplecode/CocoaEcho/Introduction/Intro.html

Searching the web ... I found CocoaHTTPServer. It builds and runs on my MacBookPro. Question: what address should I put in my IPad Safari in order to see the CocoaHTTPServer please?
 
Last edited:
If this is for your intranet ordering webapp project, why do this over sticking with something standard like Apache/MAMP? http://www.mamp.info/en/index.html

B

Hi Balamw ... I downloaded MAMP, installed it in my MacBook Pro, and ran it. Then I tried to get my IPad's Safari to see it as a WIFI server. That didn't happen ... why please? Web services is not my strong suit.
 
Are you wanting a WiFi server or a web server?

Thanx for responding Dejo.

First, I'm trying to get my arms around how the IPad operates ... confusing to me because the paradigms are so different ... no desktop for remote disks to mount, etc.
:confused:

I think a WIFI server is a local wireless LAN. I think that I connect into that LAN over 802.11 and that LAN has an outlet to the web ... is that correct? And I think that a web server has a web URL that I can connect to directly using http service.

I found some sample code for an HTTPServer ... built it and ran it on my MacBook Pro. The code for main is below. The console printed out: 2011-02-17 01:29:56.181 CocoaHTTPServer[8995:a0f] Starting server on port 64034. I'd like to access this web server from my IPad Safari, but I couldn't make that work. Can anyone help me pse?


Code:
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    HTTPServer *server = [[HTTPServer alloc] init];
    [server setType:@"_http._tcp."];
    [server setName:@"Cocoa HTTP Server"];
    [server setDocumentRoot:[NSURL fileURLWithPath:@"/"]];

    NSError *startError = nil;
    if (![server start:&startError] ) {
        NSLog(@"Error starting server: %@", startError);
        } 
    else {
        NSLog(@"Starting server on port %d", [server port]);
        }

    [[NSRunLoop currentRunLoop] run];

    [pool release];
    return 0;
    }
 
Last edited by a moderator:
It seems that you are doing this for your webapp.

Don't bring the iPad into the mix until you have it all working. I'll post more later.

Edit: Apache is the A in MAMP and is a standard HTTP server you don't need to roll your own HTTP server to develop a web app. For initial development you could even consider a hosted solution so you know it is set up correctly.

Your WiFi network will generally be created by your router or a WAP.
Apache provides web services typically on port 80 or via SSL this can be intranet or Internet services.

Test it all out via Safari on your Mac and a remote computer before you try from the iPad

B
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.