Post

Replies

Boosts

Views

Activity

How to convert Stream.streamError to CFStreamError
My App is opening streams like so: var readStream: Unmanaged<CFReadStream>? var writeStream: Unmanaged<CFWriteStream>? CFStreamCreatePairWithSocketToHost(nil, "192.168.42.1" as NSString, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;UInt32(7878), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&readStream, &writeStream) self.inputStream = readStream!.takeRetainedValue() self.outputStream = writeStream!.takeRetainedValue() if let inputStream = self.inputStream, let outputStream = self.outputStream { &#9;&#9;self.reader = StreamReader("WiFi", self.responses, onOpened: { successful in &#9;&#9;}) &#9;&#9;self.writer = StreamWriter("WiFi") &#9;&#9; &#9;&#9;CFReadStreamSetDispatchQueue(inputStream, self.workQueue) &#9;&#9;CFWriteStreamSetDispatchQueue(outputStream, self.workQueue) &#9;&#9; &#9;&#9;inputStream.delegate = self.reader &#9;&#9;inputStream.open() &#9;&#9; &#9;&#9;self.writer!.outputStream = outputStream &#9;&#9;outputStream.delegate = self.writer &#9;&#9;outputStream.open() } The StreamReader class has a onOpened callback which is empty here but controls further app flow, like so (in StreamReader): case Stream.Event.errorOccurred:     let e: CFStreamError = aStream.streamError as! CFStreamError     os_log(.default, log: log, "error occured: %{public}s", aStream.streamError?.localizedDescription ?? "")     os_log(.default, log: log, "error occured: %{public}d", aStream.streamStatus.rawValue)     if !opened {         self.onOpened?(false)     }     self.onStopped?() I try to read the raw error code, in order to comply with the local network privacy changes as mentioned in https://developer.apple.com/forums/thread/661606 for example. However, without a way to read the current status, I rely on the return code of the stream callback Stream.Event.errorOccurred. Also really thankful if someone could point me to good documentation on this.
1
0
445
Oct ’20