Differences From Artifact [6754e57a6e]:
- File
src/OFUDPSocket.m
— part of check-in
[e36455441d]
at
2018-08-04 15:35:14
on branch trunk
— Use OF_HAVE_IPV6 instead of HAVE_IPV6
This has always been wrong. (user: js, size: 12961) [annotate] [blame] [check-ins using]
To Artifact [6cab00e4d5]:
- File src/OFUDPSocket.m — part of check-in [7de9d67be9] at 2018-08-04 16:23:38 on branch trunk — Support for non-blocking UDP sockets (user: js, size: 13776) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "OFBindFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #import "socket.h" #import "socket_helpers.h" #import "resolver.h" #ifdef OF_HAVE_THREADS | > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #import "OFBindFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" #import "socket.h" #import "socket_helpers.h" #import "resolver.h" #ifdef OF_HAVE_THREADS |
︙ | ︙ | |||
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | #endif - (instancetype)init { self = [super init]; _socket = INVALID_SOCKET; return self; } - (void)dealloc { if (_socket != INVALID_SOCKET) [self close]; [super dealloc]; } - (id)copy { return [self retain]; } - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { of_resolver_result_t **results; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) union { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | #endif - (instancetype)init { self = [super init]; _socket = INVALID_SOCKET; _blocking = true; return self; } - (void)dealloc { if (_socket != INVALID_SOCKET) [self close]; [super dealloc]; } - (id)copy { return [self retain]; } - (bool)isBlocking { return _blocking; } - (void)setBlocking: (bool)enable { #if defined(HAVE_FCNTL) int flags = fcntl(_socket, F_GETFL); if (flags == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; if (enable) flags &= ~O_NONBLOCK; else flags |= O_NONBLOCK; if (fcntl(_socket, F_SETFL, flags) == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; _blocking = enable; #elif defined(OF_WINDOWS) u_long v = enable; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: of_socket_errno()]; _blocking = enable; #else OF_UNRECOGNIZED_SELECTOR #endif } - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { of_resolver_result_t **results; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) union { |
︙ | ︙ | |||
299 300 301 302 303 304 305 306 307 308 309 310 311 312 | results[0]->type | SOCK_CLOEXEC, results[0]->protocol)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif #if defined(OF_WII) || defined(OF_NINTENDO_3DS) | > > | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | results[0]->type | SOCK_CLOEXEC, results[0]->protocol)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: of_socket_errno()]; _blocking = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif #if defined(OF_WII) || defined(OF_NINTENDO_3DS) |
︙ | ︙ |