diff --git a/Sources/Socket.swift b/Sources/Socket.swift index d657cfb..f7908ae 100644 --- a/Sources/Socket.swift +++ b/Sources/Socket.swift @@ -39,11 +39,11 @@ open class Socket { return byte } - open func read(_ buffer: UnsafeMutableRawPointer, bufferSize: Int) throws -> Int { - if let ssl = tls { - return try ssl.read(buffer, size: bufferSize) + open func read(_ buffer: UnsafeMutableRawPointer, size: Int) throws -> Int { + if let tls = tls { + return try tls.read(buffer, size: size) } - let received = try ing { recv(fileDescriptor, buffer, bufferSize, 0) } + let received = try ing { recv(fileDescriptor, buffer, size, 0) } return received } diff --git a/Tests/SocketSwiftTests/SocketSwiftTests.swift b/Tests/SocketSwiftTests/SocketSwiftTests.swift index 0b870fa..31047b2 100644 --- a/Tests/SocketSwiftTests/SocketSwiftTests.swift +++ b/Tests/SocketSwiftTests/SocketSwiftTests.swift @@ -19,7 +19,7 @@ class SocketSwiftTests: XCTestCase { try! socket.write("GET / HTTP/1.1\r\n\r\n".bytes) let expected = "HTTP/1.1 " var buff = [Byte](repeating: 0, count: expected.count) - let read = try! socket.read(&buff, bufferSize: buff.count) + let read = try! socket.read(&buff, size: buff.count) XCTAssertEqual(read, buff.count) XCTAssertEqual(String(bytes: buff, encoding: .utf8), expected) } @@ -59,7 +59,7 @@ class SocketSwiftTests: XCTestCase { writableClient.close() var buffer = [Byte](repeating: 0, count: 16) - let totalBytesReceived = try! client.read(&buffer, bufferSize: 16) + let totalBytesReceived = try! client.read(&buffer, size: 16) let results = Array(buffer.prefix(totalBytesReceived))