From c05a3e7926f5f59da607db89924159d56f965f75 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 4 Jun 2008 15:27:42 -0400 Subject: [PATCH] We don't want the NULL byte at the end of the NSString when we call -receive: * Source/SocketWrapper.m: ([receive]): Substring to the last byte --- Source/SocketWrapper.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/SocketWrapper.m b/Source/SocketWrapper.m index 8d6e094..f0dfb89 100644 --- a/Source/SocketWrapper.m +++ b/Source/SocketWrapper.m @@ -165,7 +165,6 @@ int recvd = recv(sock, &buffer, sizeof(buffer), 0); // take the received data and put it into an NSData - NSMutableData *data = [NSMutableData data]; NSMutableString *str = [NSMutableString string]; // strip the length from the packet, and clear the null byte then add it to the NSData @@ -208,7 +207,8 @@ } } - return [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + NSString *tmp = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; // strip whitespace + return [tmp substringToIndex:[tmp length] - 1]; // don't want the null byte } /** -- 2.22.5