Differences From Artifact [3c38516b1b]:
- File
src/OFUDPSocket.m
— part of check-in
[62e2de30b9]
at
2015-02-16 08:39:17
on branch trunk
— Explicitly pass errno to exceptions
The old behaviour where the exception would access errno directly on
creation of the exception was very fragile. The two main problems with
it were that sometimes it would pick up an errno even though none had
been set and in other cases that when the exception was created errno
had already been overridden.This also greatly increases errno handling on Win32, especially in
conjunction with sockets. It can still be improved further, though. (user: js, size: 12842) [annotate] [blame] [check-ins using]
To Artifact [455c967f24]:
- File
src/OFUDPSocket.m
— part of check-in
[f18615e057]
at
2015-02-18 22:56:46
on branch trunk
— Add of_getsockname() and make use of it
of_getsockname() calls getsockname() after acquiring a mutex. This is
necessary as some implementations of getsockname() are not thread-safe. (user: js, size: 12874) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotConnectedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" | | > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotConnectedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #import "socket.h" #import "socket_helpers.h" #import "resolver.h" #ifdef __wii__ static uint16_t freePort = 65532; #endif #ifdef OF_HAVE_THREADS @interface OFUDPSocket_ResolveThread: OFThread |
︙ | ︙ | |||
430 431 432 433 434 435 436 | } if (port > 0) return port; #ifndef __wii__ addrLen = (socklen_t)sizeof(addr.storage); | | > | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | } if (port > 0) return port; #ifndef __wii__ addrLen = (socklen_t)sizeof(addr.storage); if (of_getsockname(_socket, (struct sockaddr*)&addr.storage, &addrLen) != 0) { int errNo = of_socket_errno(); close(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port |
︙ | ︙ |