1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GSocketClient.html
27  * outPack = gio
28  * outFile = SocketClient
29  * strct   = GSocketClient
30  * realStrct=
31  * ctorStrct=
32  * clss    = SocketClient
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_socket_client_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- gio.AsyncResultIF
50  * 	- gio.Cancellable
51  * 	- gio.IOStream
52  * 	- gio.ProxyResolver
53  * 	- gio.ProxyResolverIF
54  * 	- gio.SocketAddress
55  * 	- gio.SocketConnection
56  * 	- gio.SocketConnectable
57  * 	- gio.SocketConnectableIF
58  * structWrap:
59  * 	- GAsyncResult* -> AsyncResultIF
60  * 	- GCancellable* -> Cancellable
61  * 	- GIOStream* -> IOStream
62  * 	- GProxyResolver* -> ProxyResolverIF
63  * 	- GSocketAddress* -> SocketAddress
64  * 	- GSocketConnectable* -> SocketConnectableIF
65  * 	- GSocketConnection* -> SocketConnection
66  * module aliases:
67  * local aliases:
68  * overrides:
69  */
70 
71 module gio.SocketClient;
72 
73 public  import gtkc.giotypes;
74 
75 private import gtkc.gio;
76 private import glib.ConstructionException;
77 private import gobject.ObjectG;
78 
79 private import gobject.Signals;
80 public  import gtkc.gdktypes;
81 
82 private import glib.Str;
83 private import glib.ErrorG;
84 private import glib.GException;
85 private import gio.AsyncResultIF;
86 private import gio.Cancellable;
87 private import gio.IOStream;
88 private import gio.ProxyResolver;
89 private import gio.ProxyResolverIF;
90 private import gio.SocketAddress;
91 private import gio.SocketConnection;
92 private import gio.SocketConnectable;
93 private import gio.SocketConnectableIF;
94 
95 
96 
97 private import gobject.ObjectG;
98 
99 /**
100  * GSocketClient is a lightweight high-level utility class for connecting to
101  * a network host using a connection oriented socket type.
102  *
103  * You create a GSocketClient object, set any options you want, and then
104  * call a sync or async connect operation, which returns a GSocketConnection
105  * subclass on success.
106  *
107  * The type of the GSocketConnection object returned depends on the type of
108  * the underlying socket that is in use. For instance, for a TCP/IP connection
109  * it will be a GTcpConnection.
110  *
111  * As GSocketClient is a lightweight object, you don't need to cache it. You
112  * can just create a new one any time you need one.
113  */
114 public class SocketClient : ObjectG
115 {
116 	
117 	/** the main Gtk struct */
118 	protected GSocketClient* gSocketClient;
119 	
120 	
121 	public GSocketClient* getSocketClientStruct()
122 	{
123 		return gSocketClient;
124 	}
125 	
126 	
127 	/** the main Gtk struct as a void* */
128 	protected override void* getStruct()
129 	{
130 		return cast(void*)gSocketClient;
131 	}
132 	
133 	/**
134 	 * Sets our main struct and passes it to the parent class
135 	 */
136 	public this (GSocketClient* gSocketClient)
137 	{
138 		super(cast(GObject*)gSocketClient);
139 		this.gSocketClient = gSocketClient;
140 	}
141 	
142 	protected override void setStruct(GObject* obj)
143 	{
144 		super.setStruct(obj);
145 		gSocketClient = cast(GSocketClient*)obj;
146 	}
147 	
148 	/**
149 	 */
150 	int[string] connectedSignals;
151 	
152 	void delegate(GSocketClientEvent, SocketConnectableIF, IOStream, SocketClient)[] onListeners;
153 	/**
154 	 * Emitted when client's activity on connectable changes state.
155 	 * Among other things, this can be used to provide progress
156 	 * information about a network connection in the UI. The meanings of
157 	 *  client is about to look up connectable in DNS.
158 	 *  connection will be NULL.
159 	 *
160 	 *  client has successfully resolved connectable in DNS.
161 	 *  connection will be NULL.
162 	 *
163 	 *  client is about to make a connection to a remote host;
164 	 *  either a proxy server or the destination server itself.
165 	 *  connection is the GSocketConnection, which is not yet
166 	 *  connected.
167 	 *
168 	 *  client has successfully connected to a remote host.
169 	 *  connection is the connected GSocketConnection.
170 	 *
171 	 *  client is about to negotiate with a proxy to get it to
172 	 *  connect to connectable. connection is the
173 	 *  GSocketConnection to the proxy server.
174 	 *
175 	 *  client has negotiated a connection to connectable through
176 	 *  a proxy server. connection is the stream returned from
177 	 *  g_proxy_connect(), which may or may not be a
178 	 *  GSocketConnection.
179 	 *
180 	 *  client is about to begin a TLS handshake. connection is a
181 	 *  GTlsClientConnection.
182 	 *
183 	 *  client has successfully completed the TLS handshake.
184 	 *  connection is a GTlsClientConnection.
185 	 *
186 	 *  client has either successfully connected to connectable
187 	 *  (in which case connection is the GSocketConnection that
188 	 *  it will be returning to the caller) or has failed (in which
189 	 *  case connection is NULL and the client is about to return
190 	 *  an error).
191 	 *
192 	 * Each event except G_SOCKET_CLIENT_COMPLETE may be emitted
193 	 * multiple times (or not at all) for a given connectable (in
194 	 * particular, if client ends up attempting to connect to more than
195 	 * one address). However, if client emits the "event"
196 	 * signal at all for a given connectable, that it will always emit
197 	 * it with G_SOCKET_CLIENT_COMPLETE when it is done.
198 	 * Note that there may be additional GSocketClientEvent values in
199 	 * the future; unrecognized event values should be ignored.
200 	 * Since 2.32
201 	 * See Also
202 	 * GSocketConnection, GSocketListener
203 	 */
204 	void addOn(void delegate(GSocketClientEvent, SocketConnectableIF, IOStream, SocketClient) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
205 	{
206 		if ( !("event" in connectedSignals) )
207 		{
208 			Signals.connectData(
209 			getStruct(),
210 			"event",
211 			cast(GCallback)&callBack,
212 			cast(void*)this,
213 			null,
214 			connectFlags);
215 			connectedSignals["event"] = 1;
216 		}
217 		onListeners ~= dlg;
218 	}
219 	extern(C) static void callBack(GSocketClient* clientStruct, GSocketClientEvent event, GSocketConnectable* connectable, GIOStream* connection, SocketClient _socketClient)
220 	{
221 		foreach ( void delegate(GSocketClientEvent, SocketConnectableIF, IOStream, SocketClient) dlg ; _socketClient.onListeners )
222 		{
223 			dlg(event, ObjectG.getDObject!(SocketConnectable, SocketConnectableIF)(connectable), ObjectG.getDObject!(IOStream)(connection), _socketClient);
224 		}
225 	}
226 	
227 	
228 	/**
229 	 * Creates a new GSocketClient with the default options.
230 	 * Since 2.22
231 	 * Throws: ConstructionException GTK+ fails to create the object.
232 	 */
233 	public this ()
234 	{
235 		// GSocketClient * g_socket_client_new (void);
236 		auto p = g_socket_client_new();
237 		if(p is null)
238 		{
239 			throw new ConstructionException("null returned by g_socket_client_new()");
240 		}
241 		this(cast(GSocketClient*) p);
242 	}
243 	
244 	/**
245 	 * Tries to resolve the connectable and make a network connection to it.
246 	 * Upon a successful connection, a new GSocketConnection is constructed
247 	 * and returned. The caller owns this new object and must drop their
248 	 * reference to it when finished with it.
249 	 * The type of the GSocketConnection object returned depends on the type of
250 	 * the underlying socket that is used. For instance, for a TCP/IP connection
251 	 * it will be a GTcpConnection.
252 	 * The socket created will be the same family as the address that the
253 	 * connectable resolves to, unless family is set with g_socket_client_set_family()
254 	 * or indirectly via g_socket_client_set_local_address(). The socket type
255 	 * defaults to G_SOCKET_TYPE_STREAM but can be set with
256 	 * g_socket_client_set_socket_type().
257 	 * If a local address is specified with g_socket_client_set_local_address() the
258 	 * socket will be bound to this address before connecting.
259 	 * Since 2.22
260 	 * Params:
261 	 * connectable = a GSocketConnectable specifying the remote address.
262 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
263 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
264 	 * Throws: GException on failure.
265 	 */
266 	public SocketConnection connect(SocketConnectableIF connectable, Cancellable cancellable)
267 	{
268 		// GSocketConnection * g_socket_client_connect (GSocketClient *client,  GSocketConnectable *connectable,  GCancellable *cancellable,  GError **error);
269 		GError* err = null;
270 		
271 		auto p = g_socket_client_connect(gSocketClient, (connectable is null) ? null : connectable.getSocketConnectableTStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
272 		
273 		if (err !is null)
274 		{
275 			throw new GException( new ErrorG(err) );
276 		}
277 		
278 		
279 		if(p is null)
280 		{
281 			return null;
282 		}
283 		
284 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
285 	}
286 	
287 	/**
288 	 * This is the asynchronous version of g_socket_client_connect().
289 	 * When the operation is finished callback will be
290 	 * called. You can then call g_socket_client_connect_finish() to get
291 	 * the result of the operation.
292 	 * Since 2.22
293 	 * Params:
294 	 * connectable = a GSocketConnectable specifying the remote address.
295 	 * cancellable = a GCancellable, or NULL. [allow-none]
296 	 * callback = a GAsyncReadyCallback. [scope async]
297 	 * userData = user data for the callback. [closure]
298 	 */
299 	public void connectAsync(SocketConnectableIF connectable, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
300 	{
301 		// void g_socket_client_connect_async (GSocketClient *client,  GSocketConnectable *connectable,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
302 		g_socket_client_connect_async(gSocketClient, (connectable is null) ? null : connectable.getSocketConnectableTStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
303 	}
304 	
305 	/**
306 	 * Finishes an async connect operation. See g_socket_client_connect_async()
307 	 * Since 2.22
308 	 * Params:
309 	 * result = a GAsyncResult.
310 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
311 	 * Throws: GException on failure.
312 	 */
313 	public SocketConnection connectFinish(AsyncResultIF result)
314 	{
315 		// GSocketConnection * g_socket_client_connect_finish (GSocketClient *client,  GAsyncResult *result,  GError **error);
316 		GError* err = null;
317 		
318 		auto p = g_socket_client_connect_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err);
319 		
320 		if (err !is null)
321 		{
322 			throw new GException( new ErrorG(err) );
323 		}
324 		
325 		
326 		if(p is null)
327 		{
328 			return null;
329 		}
330 		
331 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
332 	}
333 	
334 	/**
335 	 * This is a helper function for g_socket_client_connect().
336 	 * Attempts to create a TCP connection to the named host.
337 	 * host_and_port may be in any of a number of recognized formats; an IPv6
338 	 * address, an IPv4 address, or a domain name (in which case a DNS
339 	 * lookup is performed). Quoting with [] is supported for all address
340 	 * types. A port override may be specified in the usual way with a
341 	 * colon. Ports may be given as decimal numbers or symbolic names (in
342 	 * which case an /etc/services lookup is performed).
343 	 * If no port override is given in host_and_port then default_port will be
344 	 * used as the port number to connect to.
345 	 * In general, host_and_port is expected to be provided by the user (allowing
346 	 * them to give the hostname, and a port override if necessary) and
347 	 * default_port is expected to be provided by the application.
348 	 * In the case that an IP address is given, a single connection
349 	 * attempt is made. In the case that a name is given, multiple
350 	 * connection attempts may be made, in turn and according to the
351 	 * number of address records in DNS, until a connection succeeds.
352 	 * Upon a successful connection, a new GSocketConnection is constructed
353 	 * and returned. The caller owns this new object and must drop their
354 	 * reference to it when finished with it.
355 	 * In the event of any failure (DNS error, service not found, no hosts
356 	 * connectable) NULL is returned and error (if non-NULL) is set
357 	 * accordingly.
358 	 * Since 2.22
359 	 * Params:
360 	 * hostAndPort = the name and optionally port of the host to connect to
361 	 * defaultPort = the default port to connect to
362 	 * cancellable = a GCancellable, or NULL. [allow-none]
363 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
364 	 * Throws: GException on failure.
365 	 */
366 	public SocketConnection connectToHost(string hostAndPort, ushort defaultPort, Cancellable cancellable)
367 	{
368 		// GSocketConnection * g_socket_client_connect_to_host (GSocketClient *client,  const gchar *host_and_port,  guint16 default_port,  GCancellable *cancellable,  GError **error);
369 		GError* err = null;
370 		
371 		auto p = g_socket_client_connect_to_host(gSocketClient, Str.toStringz(hostAndPort), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
372 		
373 		if (err !is null)
374 		{
375 			throw new GException( new ErrorG(err) );
376 		}
377 		
378 		
379 		if(p is null)
380 		{
381 			return null;
382 		}
383 		
384 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
385 	}
386 	
387 	/**
388 	 * This is the asynchronous version of g_socket_client_connect_to_host().
389 	 * When the operation is finished callback will be
390 	 * called. You can then call g_socket_client_connect_to_host_finish() to get
391 	 * the result of the operation.
392 	 * Since 2.22
393 	 * Params:
394 	 * hostAndPort = the name and optionally the port of the host to connect to
395 	 * defaultPort = the default port to connect to
396 	 * cancellable = a GCancellable, or NULL. [allow-none]
397 	 * callback = a GAsyncReadyCallback. [scope async]
398 	 * userData = user data for the callback. [closure]
399 	 */
400 	public void connectToHostAsync(string hostAndPort, ushort defaultPort, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
401 	{
402 		// void g_socket_client_connect_to_host_async  (GSocketClient *client,  const gchar *host_and_port,  guint16 default_port,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
403 		g_socket_client_connect_to_host_async(gSocketClient, Str.toStringz(hostAndPort), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
404 	}
405 	
406 	/**
407 	 * Finishes an async connect operation. See g_socket_client_connect_to_host_async()
408 	 * Since 2.22
409 	 * Params:
410 	 * result = a GAsyncResult.
411 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
412 	 * Throws: GException on failure.
413 	 */
414 	public SocketConnection connectToHostFinish(AsyncResultIF result)
415 	{
416 		// GSocketConnection * g_socket_client_connect_to_host_finish  (GSocketClient *client,  GAsyncResult *result,  GError **error);
417 		GError* err = null;
418 		
419 		auto p = g_socket_client_connect_to_host_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err);
420 		
421 		if (err !is null)
422 		{
423 			throw new GException( new ErrorG(err) );
424 		}
425 		
426 		
427 		if(p is null)
428 		{
429 			return null;
430 		}
431 		
432 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
433 	}
434 	
435 	/**
436 	 * Attempts to create a TCP connection to a service.
437 	 * This call looks up the SRV record for service at domain for the
438 	 * "tcp" protocol. It then attempts to connect, in turn, to each of
439 	 * the hosts providing the service until either a connection succeeds
440 	 * or there are no hosts remaining.
441 	 * Upon a successful connection, a new GSocketConnection is constructed
442 	 * and returned. The caller owns this new object and must drop their
443 	 * reference to it when finished with it.
444 	 * In the event of any failure (DNS error, service not found, no hosts
445 	 * connectable) NULL is returned and error (if non-NULL) is set
446 	 * accordingly.
447 	 * Params:
448 	 * domain = a domain name
449 	 * service = the name of the service to connect to
450 	 * cancellable = a GCancellable, or NULL. [allow-none]
451 	 * Returns: a GSocketConnection if successful, or NULL on error. [transfer full]
452 	 * Throws: GException on failure.
453 	 */
454 	public SocketConnection connectToService(string domain, string service, Cancellable cancellable)
455 	{
456 		// GSocketConnection * g_socket_client_connect_to_service (GSocketClient *client,  const gchar *domain,  const gchar *service,  GCancellable *cancellable,  GError **error);
457 		GError* err = null;
458 		
459 		auto p = g_socket_client_connect_to_service(gSocketClient, Str.toStringz(domain), Str.toStringz(service), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
460 		
461 		if (err !is null)
462 		{
463 			throw new GException( new ErrorG(err) );
464 		}
465 		
466 		
467 		if(p is null)
468 		{
469 			return null;
470 		}
471 		
472 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
473 	}
474 	
475 	/**
476 	 * This is the asynchronous version of
477 	 * g_socket_client_connect_to_service().
478 	 * Since 2.22
479 	 * Params:
480 	 * domain = a domain name
481 	 * service = the name of the service to connect to
482 	 * cancellable = a GCancellable, or NULL. [allow-none]
483 	 * callback = a GAsyncReadyCallback. [scope async]
484 	 * userData = user data for the callback. [closure]
485 	 */
486 	public void connectToServiceAsync(string domain, string service, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
487 	{
488 		// void g_socket_client_connect_to_service_async  (GSocketClient *client,  const gchar *domain,  const gchar *service,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
489 		g_socket_client_connect_to_service_async(gSocketClient, Str.toStringz(domain), Str.toStringz(service), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
490 	}
491 	
492 	/**
493 	 * Finishes an async connect operation. See g_socket_client_connect_to_service_async()
494 	 * Since 2.22
495 	 * Params:
496 	 * result = a GAsyncResult.
497 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
498 	 * Throws: GException on failure.
499 	 */
500 	public SocketConnection connectToServiceFinish(AsyncResultIF result)
501 	{
502 		// GSocketConnection * g_socket_client_connect_to_service_finish  (GSocketClient *client,  GAsyncResult *result,  GError **error);
503 		GError* err = null;
504 		
505 		auto p = g_socket_client_connect_to_service_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err);
506 		
507 		if (err !is null)
508 		{
509 			throw new GException( new ErrorG(err) );
510 		}
511 		
512 		
513 		if(p is null)
514 		{
515 			return null;
516 		}
517 		
518 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
519 	}
520 	
521 	/**
522 	 * This is a helper function for g_socket_client_connect().
523 	 * Attempts to create a TCP connection with a network URI.
524 	 * uri may be any valid URI containing an "authority" (hostname/port)
525 	 * component. If a port is not specified in the URI, default_port
526 	 * will be used. TLS will be negotiated if "tls" is TRUE.
527 	 * (GSocketClient does not know to automatically assume TLS for
528 	 * certain URI schemes.)
529 	 * Using this rather than g_socket_client_connect() or
530 	 * g_socket_client_connect_to_host() allows GSocketClient to
531 	 * determine when to use application-specific proxy protocols.
532 	 * Upon a successful connection, a new GSocketConnection is constructed
533 	 * and returned. The caller owns this new object and must drop their
534 	 * reference to it when finished with it.
535 	 * In the event of any failure (DNS error, service not found, no hosts
536 	 * connectable) NULL is returned and error (if non-NULL) is set
537 	 * accordingly.
538 	 * Since 2.26
539 	 * Params:
540 	 * uri = A network URI
541 	 * defaultPort = the default port to connect to
542 	 * cancellable = a GCancellable, or NULL. [allow-none]
543 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
544 	 * Throws: GException on failure.
545 	 */
546 	public SocketConnection connectToUri(string uri, ushort defaultPort, Cancellable cancellable)
547 	{
548 		// GSocketConnection * g_socket_client_connect_to_uri (GSocketClient *client,  const gchar *uri,  guint16 default_port,  GCancellable *cancellable,  GError **error);
549 		GError* err = null;
550 		
551 		auto p = g_socket_client_connect_to_uri(gSocketClient, Str.toStringz(uri), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
552 		
553 		if (err !is null)
554 		{
555 			throw new GException( new ErrorG(err) );
556 		}
557 		
558 		
559 		if(p is null)
560 		{
561 			return null;
562 		}
563 		
564 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
565 	}
566 	
567 	/**
568 	 * This is the asynchronous version of g_socket_client_connect_to_uri().
569 	 * When the operation is finished callback will be
570 	 * called. You can then call g_socket_client_connect_to_uri_finish() to get
571 	 * the result of the operation.
572 	 * Since 2.26
573 	 * Params:
574 	 * uri = a network uri
575 	 * defaultPort = the default port to connect to
576 	 * cancellable = a GCancellable, or NULL. [allow-none]
577 	 * callback = a GAsyncReadyCallback. [scope async]
578 	 * userData = user data for the callback. [closure]
579 	 */
580 	public void connectToUriAsync(string uri, ushort defaultPort, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
581 	{
582 		// void g_socket_client_connect_to_uri_async  (GSocketClient *client,  const gchar *uri,  guint16 default_port,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
583 		g_socket_client_connect_to_uri_async(gSocketClient, Str.toStringz(uri), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
584 	}
585 	
586 	/**
587 	 * Finishes an async connect operation. See g_socket_client_connect_to_uri_async()
588 	 * Since 2.26
589 	 * Params:
590 	 * result = a GAsyncResult.
591 	 * Returns: a GSocketConnection on success, NULL on error. [transfer full]
592 	 * Throws: GException on failure.
593 	 */
594 	public SocketConnection connectToUriFinish(AsyncResultIF result)
595 	{
596 		// GSocketConnection * g_socket_client_connect_to_uri_finish  (GSocketClient *client,  GAsyncResult *result,  GError **error);
597 		GError* err = null;
598 		
599 		auto p = g_socket_client_connect_to_uri_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err);
600 		
601 		if (err !is null)
602 		{
603 			throw new GException( new ErrorG(err) );
604 		}
605 		
606 		
607 		if(p is null)
608 		{
609 			return null;
610 		}
611 		
612 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p);
613 	}
614 	
615 	/**
616 	 * Sets the socket family of the socket client.
617 	 * If this is set to something other than G_SOCKET_FAMILY_INVALID
618 	 * then the sockets created by this object will be of the specified
619 	 * family.
620 	 * This might be useful for instance if you want to force the local
621 	 * connection to be an ipv4 socket, even though the address might
622 	 * be an ipv6 mapped to ipv4 address.
623 	 * Since 2.22
624 	 * Params:
625 	 * family = a GSocketFamily
626 	 */
627 	public void setFamily(GSocketFamily family)
628 	{
629 		// void g_socket_client_set_family (GSocketClient *client,  GSocketFamily family);
630 		g_socket_client_set_family(gSocketClient, family);
631 	}
632 	
633 	/**
634 	 * Sets the local address of the socket client.
635 	 * The sockets created by this object will bound to the
636 	 * specified address (if not NULL) before connecting.
637 	 * This is useful if you want to ensure that the local
638 	 * side of the connection is on a specific port, or on
639 	 * a specific interface.
640 	 * Since 2.22
641 	 * Params:
642 	 * address = a GSocketAddress, or NULL. [allow-none]
643 	 */
644 	public void setLocalAddress(SocketAddress address)
645 	{
646 		// void g_socket_client_set_local_address (GSocketClient *client,  GSocketAddress *address);
647 		g_socket_client_set_local_address(gSocketClient, (address is null) ? null : address.getSocketAddressStruct());
648 	}
649 	
650 	/**
651 	 * Sets the protocol of the socket client.
652 	 * The sockets created by this object will use of the specified
653 	 * protocol.
654 	 * If protocol is 0 that means to use the default
655 	 * protocol for the socket family and type.
656 	 * Since 2.22
657 	 * Params:
658 	 * protocol = a GSocketProtocol
659 	 */
660 	public void setProtocol(GSocketProtocol protocol)
661 	{
662 		// void g_socket_client_set_protocol (GSocketClient *client,  GSocketProtocol protocol);
663 		g_socket_client_set_protocol(gSocketClient, protocol);
664 	}
665 	
666 	/**
667 	 * Sets the socket type of the socket client.
668 	 * The sockets created by this object will be of the specified
669 	 * type.
670 	 * It doesn't make sense to specify a type of G_SOCKET_TYPE_DATAGRAM,
671 	 * as GSocketClient is used for connection oriented services.
672 	 * Since 2.22
673 	 * Params:
674 	 * type = a GSocketType
675 	 */
676 	public void setSocketType(GSocketType type)
677 	{
678 		// void g_socket_client_set_socket_type (GSocketClient *client,  GSocketType type);
679 		g_socket_client_set_socket_type(gSocketClient, type);
680 	}
681 	
682 	/**
683 	 * Sets the I/O timeout for sockets created by client. timeout is a
684 	 * time in seconds, or 0 for no timeout (the default).
685 	 * The timeout value affects the initial connection attempt as well,
686 	 * so setting this may cause calls to g_socket_client_connect(), etc,
687 	 * to fail with G_IO_ERROR_TIMED_OUT.
688 	 * Since 2.26
689 	 * Params:
690 	 * timeout = the timeout
691 	 */
692 	public void setTimeout(uint timeout)
693 	{
694 		// void g_socket_client_set_timeout (GSocketClient *client,  guint timeout);
695 		g_socket_client_set_timeout(gSocketClient, timeout);
696 	}
697 	
698 	/**
699 	 * Sets whether or not client attempts to make connections via a
700 	 * proxy server. When enabled (the default), GSocketClient will use a
701 	 * GProxyResolver to determine if a proxy protocol such as SOCKS is
702 	 * needed, and automatically do the necessary proxy negotiation.
703 	 * See also g_socket_client_set_proxy_resolver().
704 	 * Since 2.26
705 	 * Params:
706 	 * enable = whether to enable proxies
707 	 */
708 	public void setEnableProxy(int enable)
709 	{
710 		// void g_socket_client_set_enable_proxy (GSocketClient *client,  gboolean enable);
711 		g_socket_client_set_enable_proxy(gSocketClient, enable);
712 	}
713 	
714 	/**
715 	 * Overrides the GProxyResolver used by client. You can call this if
716 	 * you want to use specific proxies, rather than using the system
717 	 * default proxy settings.
718 	 * Note that whether or not the proxy resolver is actually used
719 	 * depends on the setting of "enable-proxy", which is not
720 	 * changed by this function (but which is TRUE by default)
721 	 * Since 2.36
722 	 * Params:
723 	 * proxyResolver = a GProxyResolver, or NULL for the
724 	 * default. [allow-none]
725 	 */
726 	public void setProxyResolver(ProxyResolverIF proxyResolver)
727 	{
728 		// void g_socket_client_set_proxy_resolver (GSocketClient *client,  GProxyResolver *proxy_resolver);
729 		g_socket_client_set_proxy_resolver(gSocketClient, (proxyResolver is null) ? null : proxyResolver.getProxyResolverTStruct());
730 	}
731 	
732 	/**
733 	 * Sets whether client creates TLS (aka SSL) connections. If tls is
734 	 * TRUE, client will wrap its connections in a GTlsClientConnection
735 	 * and perform a TLS handshake when connecting.
736 	 * Note that since GSocketClient must return a GSocketConnection,
737 	 * but GTlsClientConnection is not a GSocketConnection, this
738 	 * actually wraps the resulting GTlsClientConnection in a
739 	 * GTcpWrapperConnection when returning it. You can use
740 	 * g_tcp_wrapper_connection_get_base_io_stream() on the return value
741 	 * to extract the GTlsClientConnection.
742 	 * If you need to modify the behavior of the TLS handshake (eg, by
743 	 * setting a client-side certificate to use, or connecting to the
744 	 * "accept-certificate" signal), you can connect to
745 	 * client's "event" signal and wait for it to be
746 	 * emitted with G_SOCKET_CLIENT_TLS_HANDSHAKING, which will give you
747 	 * a chance to see the GTlsClientConnection before the handshake
748 	 * starts.
749 	 * Since 2.28
750 	 * Params:
751 	 * tls = whether to use TLS
752 	 */
753 	public void setTls(int tls)
754 	{
755 		// void g_socket_client_set_tls (GSocketClient *client,  gboolean tls);
756 		g_socket_client_set_tls(gSocketClient, tls);
757 	}
758 	
759 	/**
760 	 * Sets the TLS validation flags used when creating TLS connections
761 	 * via client. The default value is G_TLS_CERTIFICATE_VALIDATE_ALL.
762 	 * Since 2.28
763 	 * Params:
764 	 * flags = the validation flags
765 	 */
766 	public void setTlsValidationFlags(GTlsCertificateFlags flags)
767 	{
768 		// void g_socket_client_set_tls_validation_flags  (GSocketClient *client,  GTlsCertificateFlags flags);
769 		g_socket_client_set_tls_validation_flags(gSocketClient, flags);
770 	}
771 	
772 	/**
773 	 * Gets the socket family of the socket client.
774 	 * See g_socket_client_set_family() for details.
775 	 * Since 2.22
776 	 * Returns: a GSocketFamily
777 	 */
778 	public GSocketFamily getFamily()
779 	{
780 		// GSocketFamily g_socket_client_get_family (GSocketClient *client);
781 		return g_socket_client_get_family(gSocketClient);
782 	}
783 	
784 	/**
785 	 * Gets the local address of the socket client.
786 	 * See g_socket_client_set_local_address() for details.
787 	 * Since 2.22
788 	 * Returns: a GSocketAddress or NULL. Do not free. [transfer none]
789 	 */
790 	public SocketAddress getLocalAddress()
791 	{
792 		// GSocketAddress * g_socket_client_get_local_address (GSocketClient *client);
793 		auto p = g_socket_client_get_local_address(gSocketClient);
794 		
795 		if(p is null)
796 		{
797 			return null;
798 		}
799 		
800 		return ObjectG.getDObject!(SocketAddress)(cast(GSocketAddress*) p);
801 	}
802 	
803 	/**
804 	 * Gets the protocol name type of the socket client.
805 	 * See g_socket_client_set_protocol() for details.
806 	 * Since 2.22
807 	 * Returns: a GSocketProtocol
808 	 */
809 	public GSocketProtocol getProtocol()
810 	{
811 		// GSocketProtocol g_socket_client_get_protocol (GSocketClient *client);
812 		return g_socket_client_get_protocol(gSocketClient);
813 	}
814 	
815 	/**
816 	 * Gets the socket type of the socket client.
817 	 * See g_socket_client_set_socket_type() for details.
818 	 * Since 2.22
819 	 * Returns: a GSocketFamily
820 	 */
821 	public GSocketType getSocketType()
822 	{
823 		// GSocketType g_socket_client_get_socket_type (GSocketClient *client);
824 		return g_socket_client_get_socket_type(gSocketClient);
825 	}
826 	
827 	/**
828 	 * Gets the I/O timeout time for sockets created by client.
829 	 * See g_socket_client_set_timeout() for details.
830 	 * Since 2.26
831 	 * Returns: the timeout in seconds
832 	 */
833 	public uint getTimeout()
834 	{
835 		// guint g_socket_client_get_timeout (GSocketClient *client);
836 		return g_socket_client_get_timeout(gSocketClient);
837 	}
838 	
839 	/**
840 	 * Gets the proxy enable state; see g_socket_client_set_enable_proxy()
841 	 * Since 2.26
842 	 * Returns: whether proxying is enabled
843 	 */
844 	public int getEnableProxy()
845 	{
846 		// gboolean g_socket_client_get_enable_proxy (GSocketClient *client);
847 		return g_socket_client_get_enable_proxy(gSocketClient);
848 	}
849 	
850 	/**
851 	 * Gets the GProxyResolver being used by client. Normally, this will
852 	 * be the resolver returned by g_proxy_resolver_get_default(), but you
853 	 * can override it with g_socket_client_set_proxy_resolver().
854 	 * Since 2.36
855 	 * Returns: The GProxyResolver being used by client. [transfer none]
856 	 */
857 	public ProxyResolverIF getProxyResolver()
858 	{
859 		// GProxyResolver * g_socket_client_get_proxy_resolver (GSocketClient *client);
860 		auto p = g_socket_client_get_proxy_resolver(gSocketClient);
861 		
862 		if(p is null)
863 		{
864 			return null;
865 		}
866 		
867 		return ObjectG.getDObject!(ProxyResolver, ProxyResolverIF)(cast(GProxyResolver*) p);
868 	}
869 	
870 	/**
871 	 * Gets whether client creates TLS connections. See
872 	 * g_socket_client_set_tls() for details.
873 	 * Since 2.28
874 	 * Returns: whether client uses TLS
875 	 */
876 	public int getTls()
877 	{
878 		// gboolean g_socket_client_get_tls (GSocketClient *client);
879 		return g_socket_client_get_tls(gSocketClient);
880 	}
881 	
882 	/**
883 	 * Gets the TLS validation flags used creating TLS connections via
884 	 * client.
885 	 * Since 2.28
886 	 * Returns: the TLS validation flags
887 	 */
888 	public GTlsCertificateFlags getTlsValidationFlags()
889 	{
890 		// GTlsCertificateFlags g_socket_client_get_tls_validation_flags  (GSocketClient *client);
891 		return g_socket_client_get_tls_validation_flags(gSocketClient);
892 	}
893 	
894 	/**
895 	 * Enable proxy protocols to be handled by the application. When the
896 	 * indicated proxy protocol is returned by the GProxyResolver,
897 	 * GSocketClient will consider this protocol as supported but will
898 	 * not try to find a GProxy instance to handle handshaking. The
899 	 * application must check for this case by calling
900 	 * g_socket_connection_get_remote_address() on the returned
901 	 * GSocketConnection, and seeing if it's a GProxyAddress of the
902 	 * appropriate type, to determine whether or not it needs to handle
903 	 * the proxy handshaking itself.
904 	 * This should be used for proxy protocols that are dialects of
905 	 * another protocol such as HTTP proxy. It also allows cohabitation of
906 	 * proxy protocols that are reused between protocols. A good example
907 	 * is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also
908 	 * be use as generic socket proxy through the HTTP CONNECT method.
909 	 * When the proxy is detected as being an application proxy, TLS handshake
910 	 * will be skipped. This is required to let the application do the proxy
911 	 * specific handshake.
912 	 * Params:
913 	 * protocol = The proxy protocol
914 	 */
915 	public void addApplicationProxy(string protocol)
916 	{
917 		// void g_socket_client_add_application_proxy  (GSocketClient *client,  const gchar *protocol);
918 		g_socket_client_add_application_proxy(gSocketClient, Str.toStringz(protocol));
919 	}
920 }