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