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
75
76
77
|
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
75
76
77
|
-
+
-
+
-
+
-
+
|
FD_ZERO(&writeFDs);
FD_SET(cancelFD[0], &readFDs);
return self;
}
- (void)_addStreamToObserveForReading: (OFStream*)stream
- (void)_addStreamForReading: (OFStream*)stream
{
int fd = [stream fileDescriptor];
FD_SET(fd, &readFDs);
FD_SET(fd, &exceptFDs);
}
- (void)_addStreamToObserveForWriting: (OFStream*)stream
- (void)_addStreamForWriting: (OFStream*)stream
{
int fd = [stream fileDescriptor];
FD_SET(fd, &writeFDs);
FD_SET(fd, &exceptFDs);
}
- (void)_removeStreamToObserveForReading: (OFStream*)stream
- (void)_removeStreamForReading: (OFStream*)stream
{
int fd = [stream fileDescriptor];
FD_CLR(fd, &readFDs);
if (!FD_ISSET(fd, &writeFDs))
FD_CLR(fd, &exceptFDs);
}
- (void)_removeStreamToObserveForWriting: (OFStream*)stream
- (void)_removeStreamForWriting: (OFStream*)stream
{
int fd = [stream fileDescriptor];
FD_CLR(fd, &writeFDs);
if (!FD_ISSET(fd, &readFDs))
FD_CLR(fd, &exceptFDs);
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
+
|
cArray = [readStreams cArray];
count = [readStreams count];
for (i = 0; i < count; i++) {
int fileDescriptor = [cArray[i] fileDescriptor];
if (FD_ISSET(fileDescriptor, &readFDs_)) {
[delegate streamDidBecomeReadyForReading: cArray[i]];
[delegate streamIsReadyForReading: cArray[i]];
[pool releaseObjects];
}
if (FD_ISSET(fileDescriptor, &exceptFDs_)) {
[delegate streamDidReceiveException: cArray[i]];
[pool releaseObjects];
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
+
|
cArray = [writeStreams cArray];
count = [writeStreams count];
for (i = 0; i < count; i++) {
int fileDescriptor = [cArray[i] fileDescriptor];
if (FD_ISSET(fileDescriptor, &writeFDs_)) {
[delegate streamDidBecomeReadyForWriting: cArray[i]];
[delegate streamIsReadyForWriting: cArray[i]];
[pool releaseObjects];
}
if (FD_ISSET(fileDescriptor, &exceptFDs_)) {
[delegate streamDidReceiveException: cArray[i]];
[pool releaseObjects];
}
|