Re: General approach to networking/server problem?
Re: General approach to networking/server problem?
- Subject: Re: General approach to networking/server problem?
- From: Alastair Houghton <email@hidden>
- Date: Thu, 6 Aug 2009 09:16:50 +0100
On 6 Aug 2009, at 04:16, Graham Cox wrote:
A general question. Suppose I wanted to write a Cocoa application
that could be accessed via a PHP script running on another machine
on the local network, what would the general shape of the solution
look like?
:-) That's kind of a general question.
It depends on what your app is going to be doing and when this script
is going to be running.
For instance, an easy solution might be to write a Foundation tool
that uses CGI (or if you need more performance than that gets you,
FastCGI) to get its arguments (i.e. via the environment and its
standard input), then use a conventional web server to do the actual
networking part. You could either put arguments into a POST (perhaps
send a block of XML that you can then parse at the Foundation end), or
you could stick them in the URL, and so on.
The benefit of that approach is that it's easy, it gives you the
flexibility of configuration of the webserver without you having to
implement everything yourself, and on the PHP end you can use fopen()
or the curl functions or similar.
At the other end of the spectrum is the full custom server approach,
which isn't too hard either. You've got a good few choices there
though---you'd probably want to use launchd to keep your server
running, but launchd also has a number of features to help write
server apps. If you use a non-standard protocol, then at the PHP end
you can use PHP's socket functions.
There are some sample programs here that you might be interested in:
<http://developer.apple.com/samplecode/Cocoa/idxNetworking-date.html>
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden