ObjFW  Check-in [41d7910a65]

Overview
Comment:Implement -[atEndOfStream] for OFSocket.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 41d7910a654cff468680a3e1c5448a3e56dbf0bd60e629f2d0d44f118326bbd2
User & Date: js on 2009-06-09 13:10:44
Other Links: manifest | tags
Context
2009-06-09
13:21
Handle reads with a returned size of 0 safely in -[readLine]. check-in: b464ddcda5 user: js tags: trunk
13:10
Implement -[atEndOfStream] for OFSocket. check-in: 41d7910a65 user: js tags: trunk
13:01
Use #import "*.h" instead of #import <*.h> in objfw.h. check-in: b7cd1e3dc6 user: js tags: trunk
Changes

Modified src/OFSocket.h from [ddb40125e5] to [2c2229f73b].

39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58







+












#ifndef _WIN32
	int		sock;
#else
	SOCKET		sock;
#endif
	struct sockaddr	*saddr;
	socklen_t	saddr_len;
	BOOL		eos;
}

/**
 * \return A new autoreleased OFTCPSocket
 */
+ socket;

/**
 * Enables/disables non-blocking I/O.
 */
- setBlocking: (BOOL)enable;
@end

Modified src/OFSocket.m from [4843a4b3cd] to [e3b5644b59].

48
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65

66
67
68

69
70
71
72

73
74



75
76
77
78
79
80
81
82
83
48
49
50
51
52
53
54



55
56
57
58
59
60
61
62

63
64
65

66




67


68
69
70
71

72
73
74
75
76
77
78







-
-
-
+







-
+


-
+
-
-
-
-
+
-
-
+
+
+

-







	saddr = NULL;

	return self;
}

- (BOOL)atEndOfStream
{
	/* FIXME: Implement this! */

	return NO;
	return eos;
}

- (size_t)readNBytes: (size_t)size
	  intoBuffer: (char*)buf
{
	ssize_t ret;

	if (sock == INVALID_SOCKET)
	if (sock == INVALID_SOCKET || eos)
		@throw [OFNotConnectedException newWithClass: isa];

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

	if (ret == 0)
		eos = YES;

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

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf
{
	ssize_t ret;