let server = "com.hideez.port.server" } private var inPort: CFMessagePort? func startListening() { guard nil == inPort else { return } inPort = CFMessagePortCreateLocal( nil, RemoteServerPortName.client as CFString!, getInMessageCallback(), nil, nil) let runLoopSource = CFMessagePortCreateRunLoopSource(nil, inPort, 0); CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, CFRunLoopMode.commonModes); } func getInMessageCallback() -> CFMessagePortCallBack { return {(port: CFMessagePort?, messageId:Int32, data: CFData?, _: UnsafeMutableRawPointer?) -> Unmanaged<CFData>? in RemoteServer.shared.handleInMessage(port: port, messageId: messageId, data: data) } }