diff --git a/Sources/Socket.swift b/Sources/Socket.swift index 8cb1ac7..25b7fc8 100644 --- a/Sources/Socket.swift +++ b/Sources/Socket.swift @@ -1996,8 +1996,7 @@ public class Socket: SocketReader, SocketWriter { /// /// - Returns: Integer representing the number of bytes written. /// - @discardableResult - public func write(from buffer: UnsafePointer, bufSize: Int) throws -> Int { + @discardableResult public func write(from buffer: UnsafePointer, bufSize: Int) throws -> Int { // Make sure the buffer is valid... if bufSize == 0 { @@ -2050,8 +2049,10 @@ public class Socket: SocketReader, SocketWriter { #endif } if s <= 0 { + if errno == EAGAIN && !isBlocking { - // We have written out as much as we can + + // We have written out as much as we can... return sent } @@ -2069,8 +2070,7 @@ public class Socket: SocketReader, SocketWriter { /// /// - Returns: Integer representing the number of bytes written. /// - @discardableResult - public func write(from data: NSData) throws -> Int { + @discardableResult public func write(from data: NSData) throws -> Int { // If there's no data in the NSData object, why bother? Fail silently... if data.length == 0 { @@ -2087,8 +2087,7 @@ public class Socket: SocketReader, SocketWriter { /// /// - Returns: Integer representing the number of bytes written. /// - @discardableResult - public func write(from data: Data) throws -> Int { + @discardableResult public func write(from data: Data) throws -> Int { // If there's no data in the Data object, why bother? Fail silently... if data.count == 0 { @@ -2108,8 +2107,7 @@ public class Socket: SocketReader, SocketWriter { /// /// - Returns: Integer representing the number of bytes written. /// - @discardableResult - public func write(from string: String) throws -> Int { + @discardableResult public func write(from string: String) throws -> Int { return try string.nulTerminatedUTF8.withUnsafeBufferPointer() { (buffer: UnsafeBufferPointer) -> Int in