74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
uint16_t _port;
id _target;
SEL _selector;
id _context;
# ifdef OF_HAVE_BLOCKS
of_tcp_socket_async_connect_block_t _block;
# endif
OFException *_exception;
}
- initWithSourceThread: (OFThread *)sourceThread
socket: (OFTCPSocket *)socket
host: (OFString *)host
port: (uint16_t)port
target: (id)target
|
|
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
uint16_t _port;
id _target;
SEL _selector;
id _context;
# ifdef OF_HAVE_BLOCKS
of_tcp_socket_async_connect_block_t _block;
# endif
id _exception;
}
- initWithSourceThread: (OFThread *)sourceThread
socket: (OFTCPSocket *)socket
host: (OFString *)host
port: (uint16_t)port
target: (id)target
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
[self join];
# ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block(_socket, _exception);
else {
# endif
void (*func)(id, SEL, OFTCPSocket *, id, OFException *) =
(void (*)(id, SEL, OFTCPSocket *, id, OFException *))
[_target methodForSelector: _selector];
func(_target, _selector, _socket, _context, _exception);
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (id)main
{
void *pool = objc_autoreleasePoolPush();
@try {
[_socket connectToHost: _host
port: _port];
} @catch (OFException *e) {
_exception = [e retain];
}
[self performSelector: @selector(didConnect)
onThread: _sourceThread
waitUntilDone: false];
|
|
|
|
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
[self join];
# ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block(_socket, _exception);
else {
# endif
void (*func)(id, SEL, OFTCPSocket *, id, id) =
(void (*)(id, SEL, OFTCPSocket *, id, id))
[_target methodForSelector: _selector];
func(_target, _selector, _socket, _context, _exception);
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (id)main
{
void *pool = objc_autoreleasePoolPush();
@try {
[_socket connectToHost: _host
port: _port];
} @catch (id e) {
_exception = [e retain];
}
[self performSelector: @selector(didConnect)
onThread: _sourceThread
waitUntilDone: false];
|