简体   繁体   中英

Communicate between iPhone and macbook laptop

In an effort to learn more about networking I'd like to do an exercise: write some code on an iPhone and macbook laptop that allows the devices to communicate over HTTP.

How would I set this up in general? I could write a very simple web server as illustrated in Beej's Guide . Then run this and make requests from the phone. Assume the two devices will be on the same wifi network.

In this book you can find an example of how to make a network to connect a Mac OS X app with an iOS app using Bonjour.

http://my.safaribooksonline.com/book/programming/mobile/9780132757058/bonjour-and-web-servers/ch28

Hope this helps you.

Using HTTP between two apps is very inefficient. Use NSNetService and raw sockets.

NSNetService Docs

There is an example project that shows how to setup the service for publishing, connect 2 services, and consume data from a socket connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM