Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What classes do I use to make an iPhone act as a server?

I'm looking for an easy way for users to download content from an iPhone to their computer. I've seen other apps that actually turn the iPhone into a server and give the user an IP address to navigate to on their computer. I've glanced at some Apple samples, but nothing looked too much like what I was going for.

So what's 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 make a wrapper if there isn't anything available.

like image 690
Ed Marty Avatar asked Jan 26 '09 02:01

Ed Marty


People also ask

Can iCloud be used as a server?

use iCloud as a web server is impossible.

Can you run a web server on iPhone?

Want to run a simple web server off of an iPad or iPhone? If you have iSH linux shell running in iOS then you can easily start and run a simple web server directly from an iPhone or iPad.

What is iOS server?

iOS Server is a native app that offers all the features of Apple's OS X Server product for the iPad. Instead of being tied to Macintosh Hardware you can deploy iPads for your back-end infrastructure. You gain many benefits by using iPad: iPads are mobile.


2 Answers

Google Toolbox for Mac has a class called GTMHTTPServer.

Deusty Designs has a project called CocoaHTTPServer.

You can't use port 80 because it requires root access.

like image 189
Chris Lundie Avatar answered Nov 01 '22 16:11

Chris Lundie


Cocoa provides lots of support for client-side networking but not a lot for server-side.

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

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

In Objective-C, you can look at NSStream which is the Objective-C equivalent of CFStream.

like image 27
Matt Gallagher Avatar answered Nov 01 '22 15:11

Matt Gallagher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!