ObjFW  Check-in [69e41c48ff]

Overview
Comment:Throw an OFNotConnected exception when there was a clean disconnect.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 69e41c48ff3c0d7e096fa205f78c753f7b6b60a399a171ae56aacbf38fe775c4
User & Date: js on 2009-04-08 13:13:05
Other Links: manifest | tags
Context
2009-04-08
17:11
Ouch. Really. Fixed recursion loop in OFExceptions. check-in: 0c8a28c5ac user: js tags: trunk
13:13
Throw an OFNotConnected exception when there was a clean disconnect. check-in: 69e41c48ff user: js tags: trunk
2009-04-07
15:44
Returning newly allocated buffers on reading is a bad idea.
The programmer might forget that some of the data is arbitrary because
there was less data than he requested which might lead to serious
problems.
check-in: 09e6b3fc7b user: js tags: trunk
Changes

Modified src/OFTCPSocket.m from [3dac29634e] to [86db944fc0].

226
227
228
229
230
231
232
233




234
235

236
237
238
239
240
241
242
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241
242
243
244
245
246







-
+
+
+
+


+







	  intoBuffer: (uint8_t*)buf
{
	ssize_t ret;

	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: [self class]];

	if ((ret = recv(sock, (char*)buf, size, 0)) < 1)
	switch ((ret = recv(sock, (char*)buf, size, 0))) {
	case 0:
		@throw [OFNotConnectedException newWithClass: [self class]];
	case -1:
		@throw [OFReadFailedException newWithClass: [self class]
						   andSize: size];
	}

	/* This is safe, as we already checked < 1 */
	return ret;
}

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const uint8_t*)buf