ObjFW  Diff

Differences From Artifact [49e1470816]:

  • File src/OFTCPSocket.m — part of check-in [1833194867] at 2021-01-14 02:29:31 on branch trunk — Define _HPUX_ALT_XOPEN_SOCKET_API where necessary

    There is a nasty bug in HP-UX: When using the proper socket APIs that
    take a socklen_t (which is 64 bit in LP64 mode), it still calls into
    methods that expect an int - so there is a type mismatch between the
    headers and the compiled system libraries. This leads to all socklen_t
    being interpreted as 0 (due to big endian). Defining
    _HPUX_ALT_XOPEN_SOCKET_API makes it use the correct symbols in the
    system libraries instead. (user: js, size: 11571) [annotate] [blame] [check-ins using]

To Artifact [5cdf6dd0d8]:


178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193
194
195
196
197
198
199
200

201
202
203
204

205
206
207
208
209
210
211
212
213
214
215

216
217
218
219
220
221
222
223
178
179
180
181
182
183
184

185

186
187
188
189
190
191
192
193
194
195
196
197
198

199

200
201

202

203
204
205
206
207
208
209
210
211

212

213
214
215
216
217
218
219







-
+
-













-
+
-


-
+
-









-
+
-








- (void)of_closeSocket
{
	closesocket(_socket);
	_socket = INVALID_SOCKET;
}

- (void)connectToHost: (OFString *)host
- (void)connectToHost: (OFString *)host port: (uint16_t)port
		 port: (uint16_t)port
{
	void *pool = objc_autoreleasePoolPush();
	id <OFTCPSocketDelegate> delegate = _delegate;
	OFTCPSocketConnectDelegate *connectDelegate =
	    [[[OFTCPSocketConnectDelegate alloc] init] autorelease];
	OFRunLoop *runLoop = [OFRunLoop currentRunLoop];

	self.delegate = connectDelegate;
	[self asyncConnectToHost: host
			    port: port
		     runLoopMode: connectRunLoopMode];

	while (!connectDelegate->_done)
		[runLoop runMode: connectRunLoopMode
		[runLoop runMode: connectRunLoopMode beforeDate: nil];
		      beforeDate: nil];

	/* Cleanup */
	[runLoop runMode: connectRunLoopMode
	[runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]];
	      beforeDate: [OFDate date]];

	if (connectDelegate->_exception != nil)
		@throw connectDelegate->_exception;

	self.delegate = delegate;

	objc_autoreleasePoolPop(pool);
}

- (void)asyncConnectToHost: (OFString *)host
- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port
		      port: (uint16_t)port
{
	[self asyncConnectToHost: host
			    port: port
		     runLoopMode: of_run_loop_mode_default];
}

- (void)asyncConnectToHost: (OFString *)host
297
298
299
300
301
302
303
304

305
306
307
308
309
310
311
312
293
294
295
296
297
298
299

300

301
302
303
304
305
306
307







-
+
-







			   block: (delegate == nil ? block : NULL)] autorelease]
	    startWithRunLoopMode: runLoopMode];

	objc_autoreleasePoolPop(pool);
}
#endif

- (uint16_t)bindToHost: (OFString *)host
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port
		  port: (uint16_t)port
{
	const int one = 1;
	void *pool = objc_autoreleasePoolPush();
	OFData *socketAddresses;
	of_socket_address_t address;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
	int flags;