diff --git a/Sources/Socket/Packet.swift b/Sources/Socket/Packet.swift index a144b11..836e9e7 100644 --- a/Sources/Socket/Packet.swift +++ b/Sources/Socket/Packet.swift @@ -10,7 +10,7 @@ extension Socket { // Loop through all of grouped message bytes while (total < Int(length)) { - received += try recv(length: size_t(length), result: result.withUnsafeMutableBytes { $0.baseAddress! } + total, flags: flags) + received += try recv(length: size_t(length)-total, result: result.withUnsafeMutableBytes { $0.baseAddress! } + total, flags: flags) total += received // Check for recv errors @@ -30,7 +30,7 @@ extension Socket { // Loop through all of grouped message bytes while (total < Int(length)) { - read += try self.read(length: size_t(length), result: result.withUnsafeMutableBytes { $0.baseAddress! } + total) + read += try self.read(length: size_t(length)-total, result: result.withUnsafeMutableBytes { $0.baseAddress! } + total) total += read // Check for recv errors