ObjFW  Diff

Differences From Artifact [a0edfc0fdf]:

To Artifact [f8cfb3a493]:


119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

142
143
144
145

146
147
148
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
164
119
120
121
122
123
124
125

126

127
128
129
130
131
132
133
134
135
136
137
138
139

140

141
142

143

144
145
146
147
148
149
150
151
152

153

154
155
156
157
158
159
160







-
+
-













-
+
-


-
+
-









-
+
-








- (void)of_closeSocket
{
	closesocket(_socket);
	_socket = INVALID_SOCKET;
}

- (void)connectToHost: (OFString *)host
- (void)connectToHost: (OFString *)host port: (uint16_t)port
		 port: (uint16_t)port
{
	void *pool = objc_autoreleasePoolPush();
	id <OFSCTPSocketDelegate> delegate = _delegate;
	OFSCTPSocketConnectDelegate *connectDelegate =
	    [[[OFSCTPSocketConnectDelegate alloc] init] autorelease];
	OFRunLoop *runLoop = [OFRunLoop currentRunLoop];

	self.delegate = connectDelegate;
	[self asyncConnectToHost: host
			    port: port
		     runLoopMode: connectRunLoopMode];

	while (!connectDelegate->_done)
		[runLoop runMode: connectRunLoopMode
		[runLoop runMode: connectRunLoopMode beforeDate: nil];
		      beforeDate: nil];

	/* Cleanup */
	[runLoop runMode: connectRunLoopMode
	[runLoop runMode: connectRunLoopMode beforeDate: [OFDate date]];
	      beforeDate: [OFDate date]];

	if (connectDelegate->_exception != nil)
		@throw connectDelegate->_exception;

	self.delegate = delegate;

	objc_autoreleasePoolPop(pool);
}

- (void)asyncConnectToHost: (OFString *)host
- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port
		      port: (uint16_t)port
{
	[self asyncConnectToHost: host
			    port: port
		     runLoopMode: of_run_loop_mode_default];
}

- (void)asyncConnectToHost: (OFString *)host
210
211
212
213
214
215
216
217

218
219
220
221
222
223
224
225
206
207
208
209
210
211
212

213

214
215
216
217
218
219
220







-
+
-







			   block: block] autorelease]
	    startWithRunLoopMode: runLoopMode];

	objc_autoreleasePoolPop(pool);
}
#endif

- (uint16_t)bindToHost: (OFString *)host
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port
		  port: (uint16_t)port
{
	const int one = 1;
	void *pool = objc_autoreleasePoolPush();
	OFData *socketAddresses;
	of_socket_address_t address;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
	int flags;