ObjFW  Diff

Differences From Artifact [26835c8d41]:

  • File src/OFUDPSocket.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: 5054) [annotate] [blame] [check-ins using]

To Artifact [ab91d5347a]:


168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
	@throw [OFBindFailedException exceptionWithHost: host
						   port: port
						 socket: self
						  errNo: EADDRNOTAVAIL];
#endif
}

- (uint16_t)bindToHost: (OFString *)host
		  port: (uint16_t)port
{
	void *pool = objc_autoreleasePoolPush();
	OFData *socketAddresses;
	of_socket_address_t address;

	if (_socket != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

	socketAddresses = [[OFThread DNSResolver]
	    resolveAddressesForHost: host
		      addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY];

	address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0];
	of_socket_address_set_port(&address, port);

	port = [self of_bindToAddress: &address
			    extraType: 0];

	objc_autoreleasePoolPop(pool);

	return port;
}
@end







|
<















|
<






168
169
170
171
172
173
174
175

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

192
193
194
195
196
197
	@throw [OFBindFailedException exceptionWithHost: host
						   port: port
						 socket: self
						  errNo: EADDRNOTAVAIL];
#endif
}

- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port

{
	void *pool = objc_autoreleasePoolPush();
	OFData *socketAddresses;
	of_socket_address_t address;

	if (_socket != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

	socketAddresses = [[OFThread DNSResolver]
	    resolveAddressesForHost: host
		      addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY];

	address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0];
	of_socket_address_set_port(&address, port);

	port = [self of_bindToAddress: &address extraType: 0];


	objc_autoreleasePoolPop(pool);

	return port;
}
@end