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.SocketAddress 52 * - gio.SocketConnection 53 * - gio.SocketConnectableIF 54 * structWrap: 55 * - GAsyncResult* -> AsyncResultIF 56 * - GCancellable* -> Cancellable 57 * - GSocketAddress* -> SocketAddress 58 * - GSocketConnectable* -> SocketConnectableIF 59 * - GSocketConnection* -> SocketConnection 60 * module aliases: 61 * local aliases: 62 * overrides: 63 */ 64 65 module gio.SocketClient; 66 67 public import gtkc.giotypes; 68 69 private import gtkc.gio; 70 private import glib.ConstructionException; 71 private import gobject.ObjectG; 72 73 74 private import glib.Str; 75 private import glib.ErrorG; 76 private import glib.GException; 77 private import gio.AsyncResultIF; 78 private import gio.Cancellable; 79 private import gio.SocketAddress; 80 private import gio.SocketConnection; 81 private import gio.SocketConnectableIF; 82 83 84 85 private import gobject.ObjectG; 86 87 /** 88 * Description 89 * GSocketClient is a high-level utility class for connecting to a 90 * network host using a connection oriented socket type. 91 * You create a GSocketClient object, set any options you want, then 92 * call a sync or async connect operation, which returns a GSocketConnection 93 * subclass on success. 94 * The type of the GSocketConnection object returned depends on the type of 95 * the underlying socket that is in use. For instance, for a TCP/IP connection 96 * it will be a GTcpConnection. 97 */ 98 public class SocketClient : ObjectG 99 { 100 101 /** the main Gtk struct */ 102 protected GSocketClient* gSocketClient; 103 104 105 public GSocketClient* getSocketClientStruct() 106 { 107 return gSocketClient; 108 } 109 110 111 /** the main Gtk struct as a void* */ 112 protected override void* getStruct() 113 { 114 return cast(void*)gSocketClient; 115 } 116 117 /** 118 * Sets our main struct and passes it to the parent class 119 */ 120 public this (GSocketClient* gSocketClient) 121 { 122 super(cast(GObject*)gSocketClient); 123 this.gSocketClient = gSocketClient; 124 } 125 126 protected override void setStruct(GObject* obj) 127 { 128 super.setStruct(obj); 129 gSocketClient = cast(GSocketClient*)obj; 130 } 131 132 /** 133 */ 134 135 /** 136 * Enable proxy protocols to be handled by the application. When the 137 * indicated proxy protocol is returned by the GProxyResolver, 138 * GSocketClient will consider this protocol as supported but will 139 * not try find a GProxy instance to handle handshaking. The 140 * application must check for this case by calling 141 * g_socket_connection_get_remote_address() on the returned 142 * GSocketConnection, and seeing if it's a GProxyAddress of the 143 * appropriate type, to determine whether or not it needs to handle 144 * the proxy handshaking itself. 145 * This should be used for proxy protocols that are dialects of 146 * another protocol such as HTTP proxy. It also allows cohabitation of 147 * proxy protocols that are reused between protocols. A good example 148 * is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also 149 * be use as generic socket proxy through the HTTP CONNECT method. 150 * Params: 151 * protocol = The proxy protocol 152 */ 153 public void addApplicationProxy(string protocol) 154 { 155 // void g_socket_client_add_application_proxy (GSocketClient *client, const gchar *protocol); 156 g_socket_client_add_application_proxy(gSocketClient, Str.toStringz(protocol)); 157 } 158 159 /** 160 * Creates a new GSocketClient with the default options. 161 * Since 2.22 162 * Throws: ConstructionException GTK+ fails to create the object. 163 */ 164 public this () 165 { 166 // GSocketClient * g_socket_client_new (void); 167 auto p = g_socket_client_new(); 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by g_socket_client_new()"); 171 } 172 this(cast(GSocketClient*) p); 173 } 174 175 /** 176 * Tries to resolve the connectable and make a network connection to it.. 177 * Upon a successful connection, a new GSocketConnection is constructed 178 * and returned. The caller owns this new object and must drop their 179 * reference to it when finished with it. 180 * The type of the GSocketConnection object returned depends on the type of 181 * the underlying socket that is used. For instance, for a TCP/IP connection 182 * it will be a GTcpConnection. 183 * The socket created will be the same family as the the address that the 184 * connectable resolves to, unless family is set with g_socket_client_set_family() 185 * or indirectly via g_socket_client_set_local_address(). The socket type 186 * defaults to G_SOCKET_TYPE_STREAM but can be set with 187 * g_socket_client_set_socket_type(). 188 * If a local address is specified with g_socket_client_set_local_address() the 189 * socket will be bound to this address before connecting. 190 * Since 2.22 191 * Params: 192 * connectable = a GSocketConnectable specifying the remote address. 193 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 194 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 195 * Throws: GException on failure. 196 */ 197 public SocketConnection connect(SocketConnectableIF connectable, Cancellable cancellable) 198 { 199 // GSocketConnection * g_socket_client_connect (GSocketClient *client, GSocketConnectable *connectable, GCancellable *cancellable, GError **error); 200 GError* err = null; 201 202 auto p = g_socket_client_connect(gSocketClient, (connectable is null) ? null : connectable.getSocketConnectableTStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 203 204 if (err !is null) 205 { 206 throw new GException( new ErrorG(err) ); 207 } 208 209 210 if(p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 216 } 217 218 /** 219 * This is the asynchronous version of g_socket_client_connect(). 220 * When the operation is finished callback will be 221 * called. You can then call g_socket_client_connect_finish() to get 222 * the result of the operation. 223 * Since 2.22 224 * Params: 225 * connectable = a GSocketConnectable specifying the remote address. 226 * cancellable = a GCancellable, or NULL. [allow-none] 227 * callback = a GAsyncReadyCallback. [scope async] 228 * userData = user data for the callback. [closure] 229 */ 230 public void connectAsync(SocketConnectableIF connectable, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 231 { 232 // void g_socket_client_connect_async (GSocketClient *client, GSocketConnectable *connectable, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 233 g_socket_client_connect_async(gSocketClient, (connectable is null) ? null : connectable.getSocketConnectableTStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 234 } 235 236 /** 237 * Finishes an async connect operation. See g_socket_client_connect_async() 238 * Since 2.22 239 * Params: 240 * result = a GAsyncResult. 241 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 242 * Throws: GException on failure. 243 */ 244 public SocketConnection connectFinish(AsyncResultIF result) 245 { 246 // GSocketConnection * g_socket_client_connect_finish (GSocketClient *client, GAsyncResult *result, GError **error); 247 GError* err = null; 248 249 auto p = g_socket_client_connect_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err); 250 251 if (err !is null) 252 { 253 throw new GException( new ErrorG(err) ); 254 } 255 256 257 if(p is null) 258 { 259 return null; 260 } 261 262 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 263 } 264 265 /** 266 * This is a helper function for g_socket_client_connect(). 267 * Attempts to create a TCP connection to the named host. 268 * host_and_port may be in any of a number of recognised formats; an IPv6 269 * address, an IPv4 address, or a domain name (in which case a DNS 270 * lookup is performed). Quoting with [] is supported for all address 271 * types. A port override may be specified in the usual way with a 272 * colon. Ports may be given as decimal numbers or symbolic names (in 273 * which case an /etc/services lookup is performed). 274 * If no port override is given in host_and_port then default_port will be 275 * used as the port number to connect to. 276 * In general, host_and_port is expected to be provided by the user (allowing 277 * them to give the hostname, and a port overide if necessary) and 278 * default_port is expected to be provided by the application. 279 * In the case that an IP address is given, a single connection 280 * attempt is made. In the case that a name is given, multiple 281 * connection attempts may be made, in turn and according to the 282 * number of address records in DNS, until a connection succeeds. 283 * Upon a successful connection, a new GSocketConnection is constructed 284 * and returned. The caller owns this new object and must drop their 285 * reference to it when finished with it. 286 * In the event of any failure (DNS error, service not found, no hosts 287 * connectable) NULL is returned and error (if non-NULL) is set 288 * accordingly. 289 * Since 2.22 290 * Params: 291 * hostAndPort = the name and optionally port of the host to connect to 292 * defaultPort = the default port to connect to 293 * cancellable = a GCancellable, or NULL. [allow-none] 294 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 295 * Throws: GException on failure. 296 */ 297 public SocketConnection connectToHost(string hostAndPort, ushort defaultPort, Cancellable cancellable) 298 { 299 // GSocketConnection * g_socket_client_connect_to_host (GSocketClient *client, const gchar *host_and_port, guint16 default_port, GCancellable *cancellable, GError **error); 300 GError* err = null; 301 302 auto p = g_socket_client_connect_to_host(gSocketClient, Str.toStringz(hostAndPort), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 303 304 if (err !is null) 305 { 306 throw new GException( new ErrorG(err) ); 307 } 308 309 310 if(p is null) 311 { 312 return null; 313 } 314 315 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 316 } 317 318 /** 319 * This is the asynchronous version of g_socket_client_connect_to_host(). 320 * When the operation is finished callback will be 321 * called. You can then call g_socket_client_connect_to_host_finish() to get 322 * the result of the operation. 323 * Since 2.22 324 * Params: 325 * hostAndPort = the name and optionally the port of the host to connect to 326 * defaultPort = the default port to connect to 327 * cancellable = a GCancellable, or NULL. [allow-none] 328 * callback = a GAsyncReadyCallback. [scope async] 329 * userData = user data for the callback. [closure] 330 */ 331 public void connectToHostAsync(string hostAndPort, ushort defaultPort, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 332 { 333 // 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); 334 g_socket_client_connect_to_host_async(gSocketClient, Str.toStringz(hostAndPort), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 335 } 336 337 /** 338 * Finishes an async connect operation. See g_socket_client_connect_to_host_async() 339 * Since 2.22 340 * Params: 341 * result = a GAsyncResult. 342 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 343 * Throws: GException on failure. 344 */ 345 public SocketConnection connectToHostFinish(AsyncResultIF result) 346 { 347 // GSocketConnection * g_socket_client_connect_to_host_finish (GSocketClient *client, GAsyncResult *result, GError **error); 348 GError* err = null; 349 350 auto p = g_socket_client_connect_to_host_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err); 351 352 if (err !is null) 353 { 354 throw new GException( new ErrorG(err) ); 355 } 356 357 358 if(p is null) 359 { 360 return null; 361 } 362 363 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 364 } 365 366 /** 367 * Attempts to create a TCP connection to a service. 368 * This call looks up the SRV record for service at domain for the 369 * "tcp" protocol. It then attempts to connect, in turn, to each of 370 * the hosts providing the service until either a connection succeeds 371 * or there are no hosts remaining. 372 * Upon a successful connection, a new GSocketConnection is constructed 373 * and returned. The caller owns this new object and must drop their 374 * reference to it when finished with it. 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 * Params: 379 * domain = a domain name 380 * service = the name of the service to connect to 381 * cancellable = a GCancellable, or NULL. [allow-none] 382 * Returns: a GSocketConnection if successful, or NULL on error. [transfer full] 383 * Throws: GException on failure. 384 */ 385 public SocketConnection connectToService(string domain, string service, Cancellable cancellable) 386 { 387 // GSocketConnection * g_socket_client_connect_to_service (GSocketClient *client, const gchar *domain, const gchar *service, GCancellable *cancellable, GError **error); 388 GError* err = null; 389 390 auto p = g_socket_client_connect_to_service(gSocketClient, Str.toStringz(domain), Str.toStringz(service), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 391 392 if (err !is null) 393 { 394 throw new GException( new ErrorG(err) ); 395 } 396 397 398 if(p is null) 399 { 400 return null; 401 } 402 403 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 404 } 405 406 /** 407 * This is the asynchronous version of 408 * g_socket_client_connect_to_service(). 409 * Since 2.22 410 * Params: 411 * domain = a domain name 412 * service = the name of the service to connect to 413 * cancellable = a GCancellable, or NULL. [allow-none] 414 * callback = a GAsyncReadyCallback. [scope async] 415 * userData = user data for the callback. [closure] 416 */ 417 public void connectToServiceAsync(string domain, string service, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 418 { 419 // void g_socket_client_connect_to_service_async (GSocketClient *client, const gchar *domain, const gchar *service, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 420 g_socket_client_connect_to_service_async(gSocketClient, Str.toStringz(domain), Str.toStringz(service), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 421 } 422 423 /** 424 * Finishes an async connect operation. See g_socket_client_connect_to_service_async() 425 * Since 2.22 426 * Params: 427 * result = a GAsyncResult. 428 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 429 * Throws: GException on failure. 430 */ 431 public SocketConnection connectToServiceFinish(AsyncResultIF result) 432 { 433 // GSocketConnection * g_socket_client_connect_to_service_finish (GSocketClient *client, GAsyncResult *result, GError **error); 434 GError* err = null; 435 436 auto p = g_socket_client_connect_to_service_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err); 437 438 if (err !is null) 439 { 440 throw new GException( new ErrorG(err) ); 441 } 442 443 444 if(p is null) 445 { 446 return null; 447 } 448 449 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 450 } 451 452 /** 453 * This is a helper function for g_socket_client_connect(). 454 * Attempts to create a TCP connection with a network URI. 455 * uri may be any valid URI containing an "authority" (hostname/port) 456 * component. If a port is not specified in the URI, default_port 457 * will be used. TLS will be negotiated if "tls" is TRUE. 458 * (GSocketClient does not know to automatically assume TLS for 459 * certain URI schemes.) 460 * Using this rather than g_socket_client_connect() or 461 * g_socket_client_connect_to_host() allows GSocketClient to 462 * determine when to use application-specific proxy protocols. 463 * Upon a successful connection, a new GSocketConnection is constructed 464 * and returned. The caller owns this new object and must drop their 465 * reference to it when finished with it. 466 * In the event of any failure (DNS error, service not found, no hosts 467 * connectable) NULL is returned and error (if non-NULL) is set 468 * accordingly. 469 * Since 2.26 470 * Params: 471 * uri = A network URI 472 * defaultPort = the default port to connect to 473 * cancellable = a GCancellable, or NULL. [allow-none] 474 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 475 * Throws: GException on failure. 476 */ 477 public SocketConnection connectToUri(string uri, ushort defaultPort, Cancellable cancellable) 478 { 479 // GSocketConnection * g_socket_client_connect_to_uri (GSocketClient *client, const gchar *uri, guint16 default_port, GCancellable *cancellable, GError **error); 480 GError* err = null; 481 482 auto p = g_socket_client_connect_to_uri(gSocketClient, Str.toStringz(uri), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 483 484 if (err !is null) 485 { 486 throw new GException( new ErrorG(err) ); 487 } 488 489 490 if(p is null) 491 { 492 return null; 493 } 494 495 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 496 } 497 498 /** 499 * This is the asynchronous version of g_socket_client_connect_to_uri(). 500 * When the operation is finished callback will be 501 * called. You can then call g_socket_client_connect_to_uri_finish() to get 502 * the result of the operation. 503 * Since 2.26 504 * Params: 505 * uri = a network uri 506 * defaultPort = the default port to connect to 507 * cancellable = a GCancellable, or NULL. [allow-none] 508 * callback = a GAsyncReadyCallback. [scope async] 509 * userData = user data for the callback. [closure] 510 */ 511 public void connectToUriAsync(string uri, ushort defaultPort, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 512 { 513 // void g_socket_client_connect_to_uri_async (GSocketClient *client, const gchar *uri, guint16 default_port, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 514 g_socket_client_connect_to_uri_async(gSocketClient, Str.toStringz(uri), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 515 } 516 517 /** 518 * Finishes an async connect operation. See g_socket_client_connect_to_uri_async() 519 * Since 2.26 520 * Params: 521 * result = a GAsyncResult. 522 * Returns: a GSocketConnection on success, NULL on error. [transfer full] 523 * Throws: GException on failure. 524 */ 525 public SocketConnection connectToUriFinish(AsyncResultIF result) 526 { 527 // GSocketConnection * g_socket_client_connect_to_uri_finish (GSocketClient *client, GAsyncResult *result, GError **error); 528 GError* err = null; 529 530 auto p = g_socket_client_connect_to_uri_finish(gSocketClient, (result is null) ? null : result.getAsyncResultTStruct(), &err); 531 532 if (err !is null) 533 { 534 throw new GException( new ErrorG(err) ); 535 } 536 537 538 if(p is null) 539 { 540 return null; 541 } 542 543 return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p); 544 } 545 546 /** 547 * Sets the socket family of the socket client. 548 * If this is set to something other than G_SOCKET_FAMILY_INVALID 549 * then the sockets created by this object will be of the specified 550 * family. 551 * This might be useful for instance if you want to force the local 552 * connection to be an ipv4 socket, even though the address might 553 * be an ipv6 mapped to ipv4 address. 554 * Since 2.22 555 * Params: 556 * family = a GSocketFamily 557 */ 558 public void setFamily(GSocketFamily family) 559 { 560 // void g_socket_client_set_family (GSocketClient *client, GSocketFamily family); 561 g_socket_client_set_family(gSocketClient, family); 562 } 563 564 /** 565 * Sets the local address of the socket client. 566 * The sockets created by this object will bound to the 567 * specified address (if not NULL) before connecting. 568 * This is useful if you want to ensure the the local 569 * side of the connection is on a specific port, or on 570 * a specific interface. 571 * Since 2.22 572 * Params: 573 * address = a GSocketAddress, or NULL 574 */ 575 public void setLocalAddress(SocketAddress address) 576 { 577 // void g_socket_client_set_local_address (GSocketClient *client, GSocketAddress *address); 578 g_socket_client_set_local_address(gSocketClient, (address is null) ? null : address.getSocketAddressStruct()); 579 } 580 581 /** 582 * Sets the protocol of the socket client. 583 * The sockets created by this object will use of the specified 584 * protocol. 585 * If protocol is 0 that means to use the default 586 * protocol for the socket family and type. 587 * Since 2.22 588 * Params: 589 * protocol = a GSocketProtocol 590 */ 591 public void setProtocol(GSocketProtocol protocol) 592 { 593 // void g_socket_client_set_protocol (GSocketClient *client, GSocketProtocol protocol); 594 g_socket_client_set_protocol(gSocketClient, protocol); 595 } 596 597 /** 598 * Sets the socket type of the socket client. 599 * The sockets created by this object will be of the specified 600 * type. 601 * It doesn't make sense to specify a type of G_SOCKET_TYPE_DATAGRAM, 602 * as GSocketClient is used for connection oriented services. 603 * Since 2.22 604 * Params: 605 * type = a GSocketType 606 */ 607 public void setSocketType(GSocketType type) 608 { 609 // void g_socket_client_set_socket_type (GSocketClient *client, GSocketType type); 610 g_socket_client_set_socket_type(gSocketClient, type); 611 } 612 613 /** 614 * Sets the I/O timeout for sockets created by client. timeout is a 615 * time in seconds, or 0 for no timeout (the default). 616 * The timeout value affects the initial connection attempt as well, 617 * so setting this may cause calls to g_socket_client_connect(), etc, 618 * to fail with G_IO_ERROR_TIMED_OUT. 619 * Since 2.26 620 * Params: 621 * timeout = the timeout 622 */ 623 public void setTimeout(uint timeout) 624 { 625 // void g_socket_client_set_timeout (GSocketClient *client, guint timeout); 626 g_socket_client_set_timeout(gSocketClient, timeout); 627 } 628 629 /** 630 * Sets whether or not client attempts to make connections via a 631 * proxy server. When enabled (the default), GSocketClient will use a 632 * GProxyResolver to determine if a proxy protocol such as SOCKS is 633 * needed, and automatically do the necessary proxy negotiation. 634 * Since 2.26 635 * Params: 636 * enable = whether to enable proxies 637 */ 638 public void setEnableProxy(int enable) 639 { 640 // void g_socket_client_set_enable_proxy (GSocketClient *client, gboolean enable); 641 g_socket_client_set_enable_proxy(gSocketClient, enable); 642 } 643 644 /** 645 * Sets whether client creates TLS (aka SSL) connections. If tls is 646 * TRUE, client will wrap its connections in a GTlsClientConnection 647 * and perform a TLS handshake when connecting. 648 * Note that since GSocketClient must return a GSocketConnection, 649 * but GTlsClientConnection is not a GSocketConnection, this 650 * actually wraps the resulting GTlsClientConnection in a 651 * GTcpWrapperConnection when returning it. You can use 652 * g_tcp_wrapper_connection_get_base_io_stream() on the return value 653 * to extract the GTlsClientConnection. 654 * Since 2.28 655 * Params: 656 * tls = whether to use TLS 657 */ 658 public void setTls(int tls) 659 { 660 // void g_socket_client_set_tls (GSocketClient *client, gboolean tls); 661 g_socket_client_set_tls(gSocketClient, tls); 662 } 663 664 /** 665 * Sets the TLS validation flags used when creating TLS connections 666 * via client. The default value is G_TLS_CERTIFICATE_VALIDATE_ALL. 667 * Since 2.28 668 * Params: 669 * flags = the validation flags 670 */ 671 public void setTlsValidationFlags(GTlsCertificateFlags flags) 672 { 673 // void g_socket_client_set_tls_validation_flags (GSocketClient *client, GTlsCertificateFlags flags); 674 g_socket_client_set_tls_validation_flags(gSocketClient, flags); 675 } 676 677 /** 678 * Gets the socket family of the socket client. 679 * See g_socket_client_set_family() for details. 680 * Since 2.22 681 * Returns: a GSocketFamily 682 */ 683 public GSocketFamily getFamily() 684 { 685 // GSocketFamily g_socket_client_get_family (GSocketClient *client); 686 return g_socket_client_get_family(gSocketClient); 687 } 688 689 /** 690 * Gets the local address of the socket client. 691 * See g_socket_client_set_local_address() for details. 692 * Since 2.22 693 * Returns: a GSocketAddres or NULL. don't free. [transfer none] 694 */ 695 public SocketAddress getLocalAddress() 696 { 697 // GSocketAddress * g_socket_client_get_local_address (GSocketClient *client); 698 auto p = g_socket_client_get_local_address(gSocketClient); 699 700 if(p is null) 701 { 702 return null; 703 } 704 705 return ObjectG.getDObject!(SocketAddress)(cast(GSocketAddress*) p); 706 } 707 708 /** 709 * Gets the protocol name type of the socket client. 710 * See g_socket_client_set_protocol() for details. 711 * Since 2.22 712 * Returns: a GSocketProtocol 713 */ 714 public GSocketProtocol getProtocol() 715 { 716 // GSocketProtocol g_socket_client_get_protocol (GSocketClient *client); 717 return g_socket_client_get_protocol(gSocketClient); 718 } 719 720 /** 721 * Gets the socket type of the socket client. 722 * See g_socket_client_set_socket_type() for details. 723 * Since 2.22 724 * Returns: a GSocketFamily 725 */ 726 public GSocketType getSocketType() 727 { 728 // GSocketType g_socket_client_get_socket_type (GSocketClient *client); 729 return g_socket_client_get_socket_type(gSocketClient); 730 } 731 732 /** 733 * Gets the I/O timeout time for sockets created by client. 734 * See g_socket_client_set_timeout() for details. 735 * Since 2.26 736 * Returns: the timeout in seconds 737 */ 738 public uint getTimeout() 739 { 740 // guint g_socket_client_get_timeout (GSocketClient *client); 741 return g_socket_client_get_timeout(gSocketClient); 742 } 743 744 /** 745 * Gets the proxy enable state; see g_socket_client_set_enable_proxy() 746 * Since 2.26 747 * Returns: whether proxying is enabled 748 */ 749 public int getEnableProxy() 750 { 751 // gboolean g_socket_client_get_enable_proxy (GSocketClient *client); 752 return g_socket_client_get_enable_proxy(gSocketClient); 753 } 754 755 /** 756 * Gets whether client creates TLS connections. See 757 * g_socket_client_set_tls() for details. 758 * Since 2.28 759 * Returns: whether client uses TLS 760 */ 761 public int getTls() 762 { 763 // gboolean g_socket_client_get_tls (GSocketClient *client); 764 return g_socket_client_get_tls(gSocketClient); 765 } 766 767 /** 768 * Gets the TLS validation flags used creating TLS connections via 769 * client. 770 * Since 2.28 771 * Returns: the TLS validation flags 772 */ 773 public GTlsCertificateFlags getTlsValidationFlags() 774 { 775 // GTlsCertificateFlags g_socket_client_get_tls_validation_flags (GSocketClient *client); 776 return g_socket_client_get_tls_validation_flags(gSocketClient); 777 } 778 }