26
27
28
29
30
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
61
62
63
64
65
66
67
|
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
OFUNIXDatagramSocket *sock;
OFSocketAddress address1, address2;
char buffer[5];
#ifdef OF_HAVE_FILES
path = [[OFSystemInfo temporaryDirectoryPath]
stringByAppendingPathComponent: [[OFUUID UUID] UUIDString]];
#else
/*
* We can have sockets, including UNIX sockets, while file support is
* disabled.
*/
path = [OFString stringWithFormat: @"/tmp/%@",
[[OFUUID UUID] UUIDString]];
#endif
TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))
@try {
TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))
} @catch (OFBindFailedException *e) {
if (e.errNo == EAFNOSUPPORT) {
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFUNIXDatagramSocket] -[bindToPath:]: "
@"UNIX datagram sockets unsupported, skipping "
@"tests"];
objc_autoreleasePoolPop(pool);
return;
} else
@throw e;
}
@try {
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello" length: 5 receiver: &address1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
|
|
|
|
>
>
>
>
>
|
>
|
>
|
26
27
28
29
30
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
OFUNIXDatagramSocket *sock;
OFSocketAddress address1, address2;
char buffer[5];
#if defined(OF_HAVE_FILES) && !defined(OF_IOS)
path = [[OFSystemInfo temporaryDirectoryURI]
URIByAppendingPathComponent: [[OFUUID UUID] UUIDString]]
.fileSystemRepresentation;
#else
/*
* We can have sockets, including UNIX sockets, while file support is
* disabled.
*
* We also use this code path for iOS, as the temporaryDirectoryURI is
* too long on the iOS simulator.
*/
path = [OFString stringWithFormat: @"/tmp/%@",
[[OFUUID UUID] UUIDString]];
#endif
TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))
@try {
TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))
} @catch (OFBindFailedException *e) {
switch (e.errNo) {
case EAFNOSUPPORT:
case EPERM:
[OFStdOut setForegroundColor: [OFColor lime]];
[OFStdOut writeLine:
@"\r[OFUNIXDatagramSocket] -[bindToPath:]: "
@"UNIX datagram sockets unsupported, skipping "
@"tests"];
objc_autoreleasePoolPop(pool);
return;
default:
@throw e;
}
}
@try {
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello" length: 5 receiver: &address1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
|