Search code examples
iosmacosconnectionfile-transferbonjour

iOS - transfer file from iPad to mac with Bonjour


Quite a lot of webpages address this issue but I cannot find a simple (I am a begginer) explanation about how to setup a connection between iOS device and Mac computer. I read things about sockets and service publishing with Bonjour and the Apple documentation but it is quite heavy to understand since there is no tutorial and examples.

Does anyone know how to get the basics to setup a connection and send one file over the network or have a good tutorial to share?


Solution

  • Bonjour provides a way for applications to advertise their services and other applications to discover the advertised services.

    The main components of a service are

    1. the address (e.g. 10.0.1.52 in the local domain 10.0.1.1)
    2. the type (e.g. Apple Filling Protocol "_afpovertcp._tcp")
    3. the name (e.g. JustinsMacbookPro.local)
    4. the port (e.g. 5687)

    These components provide all of the necessary information for a "browser" to figure out how to network with the other application (e.g. setting up the network sockets).

    However, Bonjour does not provide a way to send data. Applications send data to other applications using sockets. If you don't want to directly use sockets then you can use high-level protocols that are built on top of sockets like FTP, HTTP, etc. I recommend giving Beej's Guide to Network Programming a read if you want to learn the basics of sending and receiving data over a network.