Lefora Free Forum
login join
Loading
640 views

Bonjour/CocoaHTTPServer

Page 1
1–2
rookie - member
1 posts

Hi Guys,

I'm fairly new to Cocoa, have done a little bit of Cocoa-Touch (and got an iPhone app on the app store for it).

But, I'm turning my eyes towards Mac programming, and I'm keenly interested in creating a Bonjour service on my mac that will communicate/execute a Terminal command and return the results to an iPhone app (as they would appear in say Terminal).

I've downloaded the CocoaHTTPServer from the Apple Reference Library and been playing around with it. I've got it running, and I can open it in a web browser, but there is nothing being displayed because nothing is set to be displayed.

So, my overall goal, will be to create a service on my Mac, which is looked at via an iPhone app. The iPhone app will have some buttons on it that tell the Mac service to perform a certain command, and return the result to the iPhone. So, what do I need to add to the CocoaHTTPServer code to say that when a certain button on the iPhone is pressed, to run this command and return it's results?

I want to steer clear of using a web page to view the results, as I currently have something similar in place. I want the results to be published to say a label set in the iPhone GUI (I appreciate I might need to open this part up in another Forum).

Apologies if this isn't very clear, but any help is appreciated.

Regards,

Dan

?
288 posts

I haven't looked at CocoaHTTPServer of Bonjour - however I think you're very close with your idea of a web page.  If you can pull a web page from your Apache server to your phone, then pulling any other data is very simple.  Somebody was wanting to create a mini-rss-reader and that much the same as here (only your returning terminal output)
http://www.cocoaforum.com/2009/12/07/mini-rss-reader/#post1

Remember the essential thing is to read the data from the server and then package it appropriately for your application.  So you might want to send the result of the terminal command wrapped in XML (or JSON) for your phone app to dissect and display.  The code to read a URL from cocoa is here:

http://www.cocoaforum.com/2009/12/12/accessing-a-website-page-source/#post1

__________________
Page 1
1–2

Locked Topic


You must be a member to post in this forum

Join Now!