ObjFW  Check-in [202daae1d1]

Overview
Comment:Fix two FIXMEs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 202daae1d16e299e2a80216aa84cbf024f920a4ffa4e91195f35d3e8579bf27d
User & Date: js on 2011-01-08 16:05:10
Other Links: manifest | tags
Context
2011-01-11
19:46
Windows calls it WSAENOTCONN. check-in: e8c1757fb8 user: js tags: trunk
2011-01-08
16:05
Fix two FIXMEs. check-in: 202daae1d1 user: js tags: trunk
15:59
Prefer -[release] over -[dealloc]. check-in: c53575653d user: js tags: trunk
Changes

Modified src/OFExceptions.h from [4c46e6fa5d] to [24104f796c].

324
325
326
327
328
329
330

331
332
333
334
335
336
337

/**
 * \brief An exception indicating a read or write to a stream failed.
 */
@interface OFReadOrWriteFailedException: OFException
{
	size_t requestedSize;

	int    errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t requestedSize;
@property (readonly) int errNo;
#endif







>







324
325
326
327
328
329
330
331
332
333
334
335
336
337
338

/**
 * \brief An exception indicating a read or write to a stream failed.
 */
@interface OFReadOrWriteFailedException: OFException
{
	size_t requestedSize;
@public
	int    errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t requestedSize;
@property (readonly) int errNo;
#endif

Modified src/OFStreamSocket.m from [688fd9e6b1] to [62e35b4e2c].

64
65
66
67
68
69
70
71
72
73




74
75

76

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97




98
99

100

101
102
103
104
105
106
107
108
	   intoBuffer: (char*)buf
{
	ssize_t ret;

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

#ifndef _WIN32
	/* FIXME: We want a sane error message on Win32 as well */
	if (eos)




		errno = ENOTCONN;
#endif



	if (eos || (ret = recv(sock, buf, size, 0)) < 0)
		@throw [OFReadFailedException newWithClass: isa
					     requestedSize: size];

	if (ret == 0)
		eos = YES;

	return ret;
}

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

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

#ifndef _WIN32
	/* FIXME: We want a sane error message on Win32 as well */
	if (eos)




		errno = ENOTCONN;
#endif



	if (eos || (ret = send(sock, buf, size, 0)) == -1)
		@throw [OFWriteFailedException newWithClass: isa
					      requestedSize: size];

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








<
<
|
>
>
>
>
|
|
>
|
>
|

















<
<
|
>
>
>
>
|
|
>
|
>
|







64
65
66
67
68
69
70


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	   intoBuffer: (char*)buf
{
	ssize_t ret;

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



	if (eos) {
		OFReadFailedException *e;

		e = [OFReadFailedException newWithClass: isa
					  requestedSize: size];
		e->errNo = ENOTCONN;

		@throw e;
	}

	if ((ret = recv(sock, buf, size, 0)) < 0)
		@throw [OFReadFailedException newWithClass: isa
					     requestedSize: size];

	if (ret == 0)
		eos = YES;

	return ret;
}

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

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



	if (eos) {
		OFWriteFailedException *e;

		e = [OFWriteFailedException newWithClass: isa
					   requestedSize: size];
		e->errNo = ENOTCONN;

		@throw e;
	}

	if ((ret = send(sock, buf, size, 0)) == -1)
		@throw [OFWriteFailedException newWithClass: isa
					      requestedSize: size];

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