Latest 0.1.3
Homepage https://github.com/nevyn/MeshPipe
License Simplified BSD
Platforms ios 7.0, osx 10.9
Authors

By Nevyn Bengtsson, 2015-08-09

MeshPipe is an IPC (inter-process communication) library for iOS using
UDP networking. It allows multiple running applications on a single iOS
device to send arbitrary data to each other. It:

  • Automatically connects to all other MeshPipe apps that are configured with the
    same port
  • Detects when other apps disconnect or disappear, giving you a list of available
    peers

Since it is based on UDP, there are some hard-wired limitations:

  • Message must fit within a single UDP datagram. The current UDP datagram max
    size on iOS is 9216 bytes.
  • Delivery is not guaranteed. Messages may or may not get through, may arrive from seemingly unavailable peers, or arrive out of order.
  • You may receive malicious or unexpected data, as any app on the phone could craft a message and send it to your app.
  • Communication is insecure, and any app on the device might listen in or even change messages.

Usage

Start out by selecting a port, and the maximum number of participating apps.

Each app will try to connect to count other apps, so don’t make this number too
large as it will create a very large number of UDP sockets.

Try somehow to choose a port and range that does not overlap with other apps’
usage of UDP or MeshPipe. Perhaps we can coordinate usage on the wiki for this
project?

Each app can also identify itself with a name. I suggest using
"(appBundleName).(nameOfLibrary)".

_pipe = [[MeshPipe alloc] initWithBasePort:12568 count:8 peerName:name delegate:self];

When other peers have connected, you can talk to them like so:

[peer sendData:[@"Hello" dataUsingEncoding:NSUTF8StringEncoding]];

Implement the delegate method to receive data:

- (void)meshPipe:(MeshPipe*)pipe receivedData:(NSData*)data fromPeer:(MeshPipePeer*)peer

You can broadcast to all peers (i e all other connected apps) by enumerating the
connected peers:

for(MeshPipePeer *peer in pipe.peers)
    [peer sendData:[@"Hello" dataUsingEncoding:NSUTF8StringEncoding]];

You can KVO on peers, or if you prefer, implement delegate methods for callbacks
when peers connect/disappear:

- (void)meshPipe:(MeshPipe*)pipe acceptedNewPeer:(MeshPipePeer*)peer
- (void)meshPipe:(MeshPipe *)pipe lostPeer:(MeshPipePeer*)peer withError:(NSError*)error

Note that on disconnection, the errors are in the MeshPipeErrorDomain domain
and are listed at the bottom of MeshPipe.h.

Usage with Cerfing

If you want to shuffle more fun kinds of data around a MeshPipe network, you can
use Cerfing, and the attached CerfingMeshPipeTransport.See the Transport target’s
main.m for a demo.

Latest podspec

{
    "name": "MeshPipe",
    "version": "0.1.3",
    "summary": "IPC library for iOS",
    "description": "MeshPipe is an IPC (inter-process communication) library for iOS using UDP networking.nIt allows multiple running applications on a single iOS device to send arbitrary data to each other.nIt:nn* Automatically connects to all other MeshPipe apps that are configured with the same portn* Detects when other apps disconnect or disappear, giving you a list of available peersnnSince it is based on UDP, there are some hard-wired limitations:nn* Message must fit within a single UDP datagram. The current UDP datagram max size on iOS is 9216 bytes.n* Delivery is not guaranteed. Messages may or may not get through, may arrive from seemingly unavailable peers, or arrive out of order.n* You may receive malicious or unexpected data, as any app on the phone could craft a message and send it to your app.n* Communication is insecure, and any app on the device might listen in or even change messages.",
    "homepage": "https://github.com/nevyn/MeshPipe",
    "license": {
        "type": "Simplified BSD",
        "file": "LICENSE"
    },
    "authors": {
        "Nevyn Bengtsson": "[email protected]"
    },
    "social_media_url": "http://twitter.com/nevyn",
    "source": {
        "git": "https://github.com/nevyn/MeshPipe.git",
        "tag": "0.1.3"
    },
    "platforms": {
        "ios": "7.0",
        "osx": "10.9"
    },
    "default_subspecs": "Core",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "MeshPipe/*.{h,m}",
            "exclude_files": "MeshPipe/main.m",
            "public_header_files": "MeshPipe/MeshPipe.h",
            "header_mappings_dir": "Cerfing",
            "dependencies": {
                "CocoaAsyncSocket": [
                    "~> 7.4"
                ],
                "GZIP": [
                    "~> 1.1"
                ]
            }
        },
        {
            "name": "CerfingMeshPipe",
            "source_files": "MeshPipe/CerfingMeshPipeTransport/*.{h,m}",
            "public_header_files": "MeshPipe/CerfingMeshPipeTransport/*.h",
            "exclude_files": "MeshPipe/CerfingMeshPipeTransport/main.m",
            "dependencies": {
                "Cerfing": [],
                "MeshPipe/Core": []
            },
            "header_mappings_dir": "Cerfing"
        }
    ]
}

Pin It on Pinterest

Share This