ObjFW  Check-in [099e939079]

Overview
Comment:Abstract int vs SOCKET as of_socket_t
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 099e939079d6cdf3ed0deef7a37e6f02f3ddce96534c9e5aec6b726b00150c2f
User & Date: js on 2015-03-22 11:42:08
Other Links: manifest | tags
Context
2015-03-30
21:32
OFException: Fix missing #ifdef / #endif check-in: 4d16add5ae user: js tags: trunk
2015-03-22
11:42
Abstract int vs SOCKET as of_socket_t check-in: 099e939079 user: js tags: trunk
10:10
OFFile: Add methods for [ac]time, rename for mtime check-in: d6ab9e2c62 user: js tags: trunk
Changes

Modified src/OFHTTPClient.m from [24ccd00731] to [7ed76f14fb].

223
224
225
226
227
228
229



230
231
232
233
234
235
236
		return [_socket isAtEndOfStream];

	return _atEndOfStream;
}

- (int)fileDescriptorForReading
{



	return [_socket fileDescriptorForReading];
}

- (bool)hasDataInReadBuffer
{
	return ([super hasDataInReadBuffer] || [_socket hasDataInReadBuffer]);
}







>
>
>







223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
		return [_socket isAtEndOfStream];

	return _atEndOfStream;
}

- (int)fileDescriptorForReading
{
	if (_socket == nil)
		return -1;

	return [_socket fileDescriptorForReading];
}

- (bool)hasDataInReadBuffer
{
	return ([super hasDataInReadBuffer] || [_socket hasDataInReadBuffer]);
}

Modified src/OFHTTPServer.m from [5b74303c4d] to [5ac9f0f46d].

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
	[_socket release];
	_socket = nil;
}

- (int)fileDescriptorForWriting
{
	if (_socket == nil)
		return (int)INVALID_SOCKET;

	return [_socket fileDescriptorForWriting];
}
@end

@interface OFHTTPServer_Connection: OFObject
{







|







277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
	[_socket release];
	_socket = nil;
}

- (int)fileDescriptorForWriting
{
	if (_socket == nil)
		return -1;

	return [_socket fileDescriptorForWriting];
}
@end

@interface OFHTTPServer_Connection: OFObject
{

Modified src/OFKernelEventObserver.h from [5fd1c2f371] to [2064104d5a].

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	OFMutableArray *_readObjects;
	OFMutableArray *_writeObjects;
	__unsafe_unretained id *_FDToObject;
	size_t _maxFD;
	OFMutableArray *_queue;
	OFDataArray *_queueInfo, *_queueFDs;
	id <OFKernelEventObserverDelegate> _delegate;
#ifndef _WIN32
	int _cancelFD[2];
#else
	SOCKET _cancelFD[2];
#endif
#ifndef OF_HAVE_PIPE
	struct sockaddr_in _cancelAddr;
#endif
#ifdef OF_HAVE_THREADS
	OFMutex *_mutex;
#endif
}








|


|
<
<







111
112
113
114
115
116
117
118
119
120
121


122
123
124
125
126
127
128
	OFMutableArray *_readObjects;
	OFMutableArray *_writeObjects;
	__unsafe_unretained id *_FDToObject;
	size_t _maxFD;
	OFMutableArray *_queue;
	OFDataArray *_queueInfo, *_queueFDs;
	id <OFKernelEventObserverDelegate> _delegate;
#ifdef OF_HAVE_PIPE
	int _cancelFD[2];
#else
	of_socket_t _cancelFD[2];


	struct sockaddr_in _cancelAddr;
#endif
#ifdef OF_HAVE_THREADS
	OFMutex *_mutex;
#endif
}

Modified src/OFStreamSocket.h from [fa0052c967] to [6843e4c621].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*!
 * @class OFStreamSocket OFStreamSocket.h ObjFW/OFStreamSocket.h
 *
 * @brief A class which provides functions to create and use stream sockets.
 */
@interface OFStreamSocket: OFStream
{
#ifndef _WIN32
	int    _socket;
#else
	SOCKET _socket;
#endif
	bool  _atEndOfStream;
}

/*!
 * @brief Returns a new, autoreleased OFTCPSocket.
 *
 * @return A new, autoreleased OFTCPSocket
 */







<
|
<
<
<
|







21
22
23
24
25
26
27

28



29
30
31
32
33
34
35
36
/*!
 * @class OFStreamSocket OFStreamSocket.h ObjFW/OFStreamSocket.h
 *
 * @brief A class which provides functions to create and use stream sockets.
 */
@interface OFStreamSocket: OFStream
{

	of_socket_t _socket;



	bool _atEndOfStream;
}

/*!
 * @brief Returns a new, autoreleased OFTCPSocket.
 *
 * @return A new, autoreleased OFTCPSocket
 */

Modified src/OFStreamSocket.m from [c547367b26] to [2a1777ff58].

132
133
134
135
136
137
138



139
140
141
142
143
144
145
146
147
148
149
150



151
152
153
154
155
156
157
#endif

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _socket;
#else



	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}

- (int)fileDescriptorForWriting
{
#ifndef _WIN32
	return _socket;
#else



	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}








>
>
>












>
>
>







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#endif

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _socket;
#else
	if (_socket == INVALID_SOCKET)
		return -1;

	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}

- (int)fileDescriptorForWriting
{
#ifndef _WIN32
	return _socket;
#else
	if (_socket == INVALID_SOCKET)
		return -1;

	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}

Modified src/OFUDPSocket.h from [efd1a5e773] to [40843cdaf1].

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 *	    so context can be associated with a socket. Using a socket in more
 *	    than one thread at the same time is not thread-safe, even if copy
 *	    was called to create one "instance" for every thread!
 */
@interface OFUDPSocket: OFObject <OFCopying, OFReadyForReadingObserving,
    OFReadyForWritingObserving>
{
#ifndef _WIN32
	int    _socket;
#else
	SOCKET _socket;
#endif
}

/*!
 * @brief Returns a new, autoreleased OFUDPSocket.
 *
 * @return A new, autoreleased OFUDPSocket
 */







<
|
<
<
<







83
84
85
86
87
88
89

90



91
92
93
94
95
96
97
 *	    so context can be associated with a socket. Using a socket in more
 *	    than one thread at the same time is not thread-safe, even if copy
 *	    was called to create one "instance" for every thread!
 */
@interface OFUDPSocket: OFObject <OFCopying, OFReadyForReadingObserving,
    OFReadyForWritingObserving>
{

	of_socket_t _socket;



}

/*!
 * @brief Returns a new, autoreleased OFUDPSocket.
 *
 * @return A new, autoreleased OFUDPSocket
 */

Modified src/OFUDPSocket.m from [455c967f24] to [5a2d407327].

554
555
556
557
558
559
560



561
562
563
564
565
566
567
568
569
570
571
572



573
574
575
576
577
578
579
}

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _socket;
#else



	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}

- (int)fileDescriptorForWriting
{
#ifndef _WIN32
	return _socket;
#else



	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}








>
>
>












>
>
>







554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
}

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _socket;
#else
	if (_socket == INVALID_SOCKET)
		return -1;

	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}

- (int)fileDescriptorForWriting
{
#ifndef _WIN32
	return _socket;
#else
	if (_socket == INVALID_SOCKET)
		return -1;

	if (_socket > INT_MAX)
		@throw [OFOutOfRangeException exception];

	return (int)_socket;
#endif
}

Modified src/socket.h from [3d1ffffaa0] to [046f5f35a5].

61
62
63
64
65
66
67






68
69
70
71
72
73
74
75
76
77
78
79
80
	uint8_t	       ss_len;
	sa_family_t    ss_family;
	in_port_t      ss_data1;
	struct in_addr ss_data2;
	int8_t	       ss_data3[8];
};
#endif







#ifdef __cplusplus
extern "C" {
#endif
extern bool of_socket_init(void);
extern int of_socket_errno(void);
# ifndef __wii__
extern int of_getsockname(int socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len);
# endif
#ifdef __cplusplus
}
#endif







>
>
>
>
>
>







|





61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
	uint8_t	       ss_len;
	sa_family_t    ss_family;
	in_port_t      ss_data1;
	struct in_addr ss_data2;
	int8_t	       ss_data3[8];
};
#endif

#ifndef _WIN32
typedef int of_socket_t;
#else
typedef SOCKET of_socket_t;
#endif

#ifdef __cplusplus
extern "C" {
#endif
extern bool of_socket_init(void);
extern int of_socket_errno(void);
# ifndef __wii__
extern int of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len);
# endif
#ifdef __cplusplus
}
#endif

Modified src/socket.m from [a024642fe6] to [a318aca5b3].

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176

	return 0;
#endif
}

#ifndef __wii__
int
of_getsockname(int socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len)
{
	int ret;

# ifdef OF_HAVE_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exception];







|







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176

	return 0;
#endif
}

#ifndef __wii__
int
of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len)
{
	int ret;

# ifdef OF_HAVE_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exception];