SwiftDSSocket
Features
Full Delegate Support
- every operation invokes a call to your delagate method.
IPv6 Support
- listens only on IPv6 protocol but accepts both IPv4 and IPv6 incoming connections.
- conforms to Apple's new App Store restriction on IPv6 only environment with NAT64/DNS64.
DNS Enabled
- takes advantage of sythesized IPv6 address introduced in
iOS 9 and OS X 10.11 for better IPv6 support.
- uses GCD to do DNS concurrently and connect to the first reachable address.
KEXT Bi-directional Interaction
- takes a bundle ID to interact with your KEXT like TCP stream.
Using SwiftDSSocket
Including in your project
CocoaPods
platform :ios, '10.0'
target 'MyApp' do
use_frameworks!
pod 'SwiftDSSocket'
end
Carthage
github "csujedihy/SwiftDSSocket"
Documentation
http://cocoadocs.org/docsets/SwiftDSSocket/
Example:
The following example creates a default SwiftDSSocket instance and then immediately starts listening on port 9999 and echoes back everything sent to this server.
Simply use telnet 127.0.0.1 9999 to test it.
import Cocoa
import SwiftDSSocket
class ViewController: NSViewController {
var client: SwiftDSSocket?
var server: SwiftDSSocket?
let ServerTag = 0
override func viewDidLoad() {
super.viewDidLoad()
server = SwiftDSSocket(delegate: self, delegateQueue: .main, type: .tcp)
try? server?.accept(onPort: 9999)
}
}
extension ViewController: SwiftDSSocketDelegate {
func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket) {
newSocket.readData(tag: ServerTag)
}
func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int) {
sock.write(data: data, tag: ServerTag)
sock.readData(tag: ServerTag)
}
}