-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Description
I'm not reciving zero bytes when the socket loses connection. Could something have changed regarding this?
It used to return bytesRead = 0 when the connection was closed.
socketQueue.async { [weak self] in
var readData = Data()
var shouldKeepRunning = true
do {
repeat {
let bytesRead = try socket.read(into: &readData)
if bytesRead > 0 {
let readString = String(data: readData, encoding: .utf8) ?? ""
self?.gotInput(string: readString)
readData = Data()
} else {
shouldKeepRunning = false
break
}
} while shouldKeepRunning
// close socket when bytesRead is zero
socket.close()
self?.connectionClosed()
} catch {
self?.status = .error(message: error.localizedDescription)
log.error("Read error: \(error). Read data: \(readData)")
}
}Metadata
Metadata
Assignees
Labels
No labels