Differences From Artifact [deff42ec22]:
- File
src/socket.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 5419) [annotate] [blame] [check-ins using]
To Artifact [1832892042]:
- File
src/socket.m
— part of check-in
[12b8a7552e]
at
2016-03-27 23:10:53
on branch trunk
— Add socket support for Nintendo 3DS
This removes the port registry that existed for the Wii and instead
tries binding to random ports in a loop until it succeeds or errno is
not EADDRINUSE. This is done for the Wii and Nintendo 3DS now.This also includes several other socket-related cleanups. (user: js, size: 4219) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #import "OFException.h" /* For some E* -> WSAE* defines */ #import "OFInvalidArgumentException.h" #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #import "socket.h" #ifdef OF_HAVE_THREADS # include "threading.h" static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; #ifdef OF_WII # ifdef OF_HAVE_THREADS | > > > > > > > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #ifdef OF_NINTENDO_3DS # include <malloc.h> /* For memalign() */ #endif #include <errno.h> #import "OFException.h" /* For some E* -> WSAE* defines */ #import "OFInvalidArgumentException.h" #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #import "socket.h" #ifdef OF_HAVE_THREADS # include "threading.h" #endif #ifdef OF_NINTENDO_3DS # include <3ds/types.h> # include <3ds/services/soc.h> #endif #ifdef OF_HAVE_THREADS static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; #ifdef OF_WII # ifdef OF_HAVE_THREADS |
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) return; #elif defined(OF_WII) if (net_init() < 0) return; #endif #ifdef OF_HAVE_THREADS if (!of_mutex_new(&mutex)) return; # ifdef OF_WII | > > > > > > > > > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) return; #elif defined(OF_WII) if (net_init() < 0) return; #elif defined(OF_NINTENDO_3DS) void *ctx; if ((ctx = memalign(0x1000, 0x100000)) == NULL) return; if (socInit(ctx, 0x100000) != 0) return; atexit((void(*))socExit); #endif #ifdef OF_HAVE_THREADS if (!of_mutex_new(&mutex)) return; # ifdef OF_WII |
︙ | ︙ | |||
195 196 197 198 199 200 201 | # ifdef OF_HAVE_THREADS if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; # endif return ret; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 216 217 218 219 220 221 222 223 | # ifdef OF_HAVE_THREADS if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; # endif return ret; } #endif |