ObjFW  Diff

Differences From Artifact [dac9c59275]:

To Artifact [63e1f39b43]:


81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96

97

98
99
100
101
102
103
104







-
+








-
+
-







# endif
		else
			OF_ENSURE(0);
	} else {
#endif
		if ([_delegate respondsToSelector:
		    @selector(socket:didConnectToHost:port:exception:)])
			[_delegate    socket: _socket
			[_delegate socket: _socket
			    didConnectToHost: _host
					port: _port
				   exception: _exception];
#ifdef OF_HAVE_BLOCKS
	}
#endif
}

- (void)of_socketDidConnect: (id)sock
- (void)of_socketDidConnect: (id)sock exception: (id)exception
		  exception: (id)exception
{
	if (exception != nil) {
		/*
		 * self might be retained only by the pending async requests,
		 * which we're about to cancel.
		 */
		[[self retain] autorelease];
121
122
123
124
125
126
127
128

129
130
131
132
133
134
135
136
120
121
122
123
124
125
126

127

128
129
130
131
132
133
134







-
+
-







			    @selector(tryNextAddressWithRunLoopMode:);
			OFTimer *timer = [OFTimer
			    timerWithTimeInterval: 0
					   target: self
					 selector: selector
					   object: runLoop.currentMode
					  repeats: false];
			[runLoop addTimer: timer
			[runLoop addTimer: timer forMode: runLoop.currentMode];
				  forMode: runLoop.currentMode];
		}

		return;
	}

	[self didConnect];
}
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162
145
146
147
148
149
150
151

152

153
154
155
156
157
158
159







-
+
-







{
	of_socket_address_t address = *(const of_socket_address_t *)
	    [_socketAddresses itemAtIndex: _socketAddressesIndex++];
	int errNo;

	of_socket_address_set_port(&address, _port);

	if (![_socket of_createSocketForAddress: &address
	if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
					  errNo: &errNo]) {
		if (_socketAddressesIndex >= _socketAddresses.count) {
			_exception = [[OFConnectionFailedException alloc]
			    initWithHost: _host
				    port: _port
				  socket: _socket
				   errNo: errNo];
			[self didConnect];
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
194
176
177
178
179
180
181
182

183

184
185
186
187
188
189
190







-
+
-







	 * FIXME: Use a different thread as a work around.
	 */
	[_socket setCanBlock: true];
#else
	[_socket setCanBlock: false];
#endif

	if (![_socket of_connectSocketToAddress: &address
	if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
					  errNo: &errNo]) {
#if !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
		if (errNo == EINPROGRESS) {
			[OFRunLoop of_addAsyncConnectForSocket: _socket
							  mode: runLoopMode
						      delegate: self];
			return;
		} else {