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.SocketConnectableIF; 26 27 private import gio.SocketAddressEnumerator; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtkc.gio; 31 public import gtkc.giotypes; 32 33 34 /** 35 * Objects that describe one or more potential socket endpoints 36 * implement #GSocketConnectable. Callers can then use 37 * g_socket_connectable_enumerate() to get a #GSocketAddressEnumerator 38 * to try out each socket address in turn until one succeeds, as shown 39 * in the sample code below. 40 * 41 * |[<!-- language="C" --> 42 * MyConnectionType * 43 * connect_to_host (const char *hostname, 44 * guint16 port, 45 * GCancellable *cancellable, 46 * GError **error) 47 * { 48 * MyConnection *conn = NULL; 49 * GSocketConnectable *addr; 50 * GSocketAddressEnumerator *enumerator; 51 * GSocketAddress *sockaddr; 52 * GError *conn_error = NULL; 53 * 54 * addr = g_network_address_new (hostname, port); 55 * enumerator = g_socket_connectable_enumerate (addr); 56 * g_object_unref (addr); 57 * 58 * // Try each sockaddr until we succeed. Record the first connection error, 59 * // but not any further ones (since they'll probably be basically the same 60 * // as the first). 61 * while (!conn && (sockaddr = g_socket_address_enumerator_next (enumerator, cancellable, error)) 62 * { 63 * conn = connect_to_sockaddr (sockaddr, conn_error ? NULL : &conn_error); 64 * g_object_unref (sockaddr); 65 * } 66 * g_object_unref (enumerator); 67 * 68 * if (conn) 69 * { 70 * if (conn_error) 71 * { 72 * // We couldn't connect to the first address, but we succeeded 73 * // in connecting to a later address. 74 * g_error_free (conn_error); 75 * } 76 * return conn; 77 * } 78 * else if (error) 79 * { 80 * /// Either initial lookup failed, or else the caller cancelled us. 81 * if (conn_error) 82 * g_error_free (conn_error); 83 * return NULL; 84 * } 85 * else 86 * { 87 * g_error_propagate (error, conn_error); 88 * return NULL; 89 * } 90 * } 91 * ]| 92 */ 93 public interface SocketConnectableIF{ 94 /** Get the main Gtk struct */ 95 public GSocketConnectable* getSocketConnectableStruct(bool transferOwnership = false); 96 97 /** the main Gtk struct as a void* */ 98 protected void* getStruct(); 99 100 101 /** 102 * Creates a #GSocketAddressEnumerator for @connectable. 103 * 104 * Returns: a new #GSocketAddressEnumerator. 105 * 106 * Since: 2.22 107 */ 108 public SocketAddressEnumerator enumerate(); 109 110 /** 111 * Creates a #GSocketAddressEnumerator for @connectable that will 112 * return #GProxyAddresses for addresses that you must connect 113 * to via a proxy. 114 * 115 * If @connectable does not implement 116 * g_socket_connectable_proxy_enumerate(), this will fall back to 117 * calling g_socket_connectable_enumerate(). 118 * 119 * Returns: a new #GSocketAddressEnumerator. 120 * 121 * Since: 2.26 122 */ 123 public SocketAddressEnumerator proxyEnumerate(); 124 125 /** 126 * Format a #GSocketConnectable as a string. This is a human-readable format for 127 * use in debugging output, and is not a stable serialization format. It is not 128 * suitable for use in user interfaces as it exposes too much information for a 129 * user. 130 * 131 * If the #GSocketConnectable implementation does not support string formatting, 132 * the implementation’s type name will be returned as a fallback. 133 * 134 * Returns: the formatted string 135 * 136 * Since: 2.48 137 */ 138 public string toString(); 139 }