IOS as a web server

I saw that there are several applications on the App Store that allow other computers to make an http connection to iPhone / iPad devices to transfer files. The web service seemed to be running on an iOS device. Curious how this is done / which class was used?

Thank.

+49
ios objective-c iphone cocoa-touch ipad
Jul 24 2018-11-11T00:
source share
4 answers

Just display the IP address of the device, open the socket for listening in the application running on the iOS device, and execute the http protocol. There are several third-party libraries that can do most of the hard work for you:

CocoaHTTPServer or iPhoneHTTPServer3, or SimpleWebSocketServer, or MultithreadedHTTPServer3

+46
Jul 24 '11 at 4:12
source share

As before, the best choice is to use a third-party library for this. There are basically two libraries for doing this work: CocoaHTTPServer and MongooseDaemon .

Both of them have an Objective-C API, but MongooseDaemon is just a Mongoose HTTP server shell written in plain c, while CocoaHTTPServer is completely written in Objective-C.

We decided to go with CocoaHTTPServer for a few simple reasons:

  • Even the simplest property, such as setting the document directory for the HTTP server, does not exist in MongooseDaemon. You must change the #define in the included source file to be able to change it by default, which indicates NSHomeDirectory() .
  • The MongooseDaemon library currently contains warnings about deprecated methods used in the Objective-C shell.
  • CocoaHTTPServer knows things like Bonjour or WebDav, while Mongoose just provides the basics.
  • CocoaHTTPServer comes with many examples that range from simple HTTP servers, passwd, SSL / TLS, or WebDav HTTP server.
  • CocoaHTTPServer works with GCD to enable multithreading.
+19
Aug 05 2018-12-12T00:
source share

You can use GCDWebServer

It is a state-of-the-art web server for iOS and MacOS, based on a large central dispatch.

+17
Jul 09 '14 at 13:34
source share

MongooseDaemon is also a good choice.

https://github.com/face/MongooseDaemon

+9
Oct 21 '11 at 4:19
source share



All Articles