Skip to content

Framework to send UDP broadcast messages and listen to responses using a Dispatch source.

License

Notifications You must be signed in to change notification settings

dkpoulsen/UDPBroadcastConnection

 
 

Repository files navigation

UDPBroadcastConnection

Platform iOS11+

Language: Swift 4.0

Carthage compatible

Framework to send UDP broadcast messages and listen to responses using a Dispatch dispatch source.

Requirements

iOS 9.3+, Swift 4.0

Usage

An example app is included demonstrating UDPBroadcastConnection's functionality. The example probably won't work for you out of the box since you need someone to listen and respond on the correct UDP port on your network.

Getting Started

Create a UDPBroadcastConnection on port 35602 with a closure that handles the response:

broadcastConnection = UDPBroadcastConnection(port: 35602) { [unowned self] (response: (ipAddress: String, port: Int, response: [UInt8])) -> Void in
    print("Received from \(response.ipAddress):\(response.port):\n\n\(response.response)")
}

Note: Make sure to keep a strong reference to broadcastConnection (e.g. by storing it in a property).

Installation

Carthage

Add the following line to your Cartfile.

github "gunterhager/UDPBroadcastConnection"

Then run carthage update.

Manually

Just drag and drop the .swift files in the UDPBroadcastConnection folder into your project.

License

UDPBroadcastConnection is available under the MIT license. See the LICENSE file for details.

Made with ❤ at all about apps.

all about apps

About

Framework to send UDP broadcast messages and listen to responses using a Dispatch source.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 85.0%
  • Objective-C 15.0%