31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-
-
-
-
-
-
-
-
-
-
+
-
|
#import "OFWriteFailedException.h"
#import "socket_helpers.h"
@implementation OFStreamSocket
+ (void)initialize
{
#ifdef _WIN32
WSADATA wsa;
#endif
if (self != [OFStreamSocket class])
return;
#if defined(_WIN32)
if (WSAStartup(MAKEWORD(2, 0), &wsa))
@throw [OFInitializationFailedException
exceptionWithClass: self];
#elif defined(__wii__)
if (net_init() < 0)
if (!of_init_sockets())
@throw [OFInitializationFailedException
exceptionWithClass: self];
#endif
}
+ (instancetype)socket
{
return [[[self alloc] init] autorelease];
}
|