What classes do I use to turn iPhone into a server?

I am looking for an easy way for users to download content from iPhone to their computer. I saw other applications that actually turn the iPhone into a server and give the user an IP address to go to their computer. I looked at some Apple samples, but nothing looked too much like what I was going to do.

So, what is the easiest way to make a server that listens on TCP port 80 (even better, an HTTP server) and sends responses? Hopefully using Objective-C classes, but I can do a wrapper if there is nothing available.

+6
iphone cocoa-touch
source share
3 answers

Google Toolbox for Mac has a class called GTMHTTPServer .

Deusty Designs has a project called CocoaHTTPServer .

You cannot use port 80 because it requires root access.

+4
source share

Cocoa provides great support for the client network, but not for the server side.

At the lowest level, you can use regular BSD sockets.

The next level up is CoreFoundation (simple C, but using Cocoa types). The relevant CoreFoundation APIs are CFNetwork , CFSocket and CFStream ( CFStream is a file stream that can have its source through the network - it is not a System V Stream-style network stream).

In Objective-C, you can watch NSStream , the equivalent of Objective-C CFStream .

+2
source share

There is a good O'Reilly article on setting up a simple server.

How to create a Cocoa web server

It uses NSFileHandle and NSSocketPort to configure listener requests and processing. He is also adept at using BSD sockets. I was lucky with this approach in the past.

It was written back in 2006, and I haven't used it in an iPhone project yet, but the classes it uses are pretty common. I would give him a chance to fight for the iPhone project.

0
source share

All Articles