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.InetSocketAddress; 26 27 private import gio.InetAddress; 28 private import gio.SocketAddress; 29 private import glib.ConstructionException; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gtkc.gio; 33 public import gtkc.giotypes; 34 35 36 /** 37 * An IPv4 or IPv6 socket address; that is, the combination of a 38 * #GInetAddress and a port number. 39 */ 40 public class InetSocketAddress : SocketAddress 41 { 42 /** the main Gtk struct */ 43 protected GInetSocketAddress* gInetSocketAddress; 44 45 /** Get the main Gtk struct */ 46 public GInetSocketAddress* getInetSocketAddressStruct() 47 { 48 return gInetSocketAddress; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected override void* getStruct() 53 { 54 return cast(void*)gInetSocketAddress; 55 } 56 57 protected override void setStruct(GObject* obj) 58 { 59 gInetSocketAddress = cast(GInetSocketAddress*)obj; 60 super.setStruct(obj); 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (GInetSocketAddress* gInetSocketAddress, bool ownedRef = false) 67 { 68 this.gInetSocketAddress = gInetSocketAddress; 69 super(cast(GSocketAddress*)gInetSocketAddress, ownedRef); 70 } 71 72 /** 73 */ 74 75 public static GType getType() 76 { 77 return g_inet_socket_address_get_type(); 78 } 79 80 /** 81 * Creates a new #GInetSocketAddress for @address and @port. 82 * 83 * Params: 84 * address = a #GInetAddress 85 * port = a port number 86 * 87 * Return: a new #GInetSocketAddress 88 * 89 * Since: 2.22 90 * 91 * Throws: ConstructionException GTK+ fails to create the object. 92 */ 93 public this(InetAddress address, ushort port) 94 { 95 auto p = g_inet_socket_address_new((address is null) ? null : address.getInetAddressStruct(), port); 96 97 if(p is null) 98 { 99 throw new ConstructionException("null returned by new"); 100 } 101 102 this(cast(GInetSocketAddress*) p, true); 103 } 104 105 /** 106 * Creates a new #GInetSocketAddress for @address and @port. 107 * 108 * If @address is an IPv6 address, it can also contain a scope ID 109 * (separated from the address by a "<literal>%</literal>"). 110 * 111 * Params: 112 * address = the string form of an IP address 113 * port = a port number 114 * 115 * Return: a new #GInetSocketAddress, or %NULL if @address cannot be 116 * parsed. 117 * 118 * Since: 2.40 119 * 120 * Throws: ConstructionException GTK+ fails to create the object. 121 */ 122 public this(string address, uint port) 123 { 124 auto p = g_inet_socket_address_new_from_string(Str.toStringz(address), port); 125 126 if(p is null) 127 { 128 throw new ConstructionException("null returned by new_from_string"); 129 } 130 131 this(cast(GInetSocketAddress*) p, true); 132 } 133 134 /** 135 * Gets @address's #GInetAddress. 136 * 137 * Return: the #GInetAddress for @address, which must be 138 * g_object_ref()'d if it will be stored 139 * 140 * Since: 2.22 141 */ 142 public InetAddress getAddress() 143 { 144 auto p = g_inet_socket_address_get_address(gInetSocketAddress); 145 146 if(p is null) 147 { 148 return null; 149 } 150 151 return ObjectG.getDObject!(InetAddress)(cast(GInetAddress*) p); 152 } 153 154 /** 155 * Gets the `sin6_flowinfo` field from @address, 156 * which must be an IPv6 address. 157 * 158 * Return: the flowinfo field 159 * 160 * Since: 2.32 161 */ 162 public uint getFlowinfo() 163 { 164 return g_inet_socket_address_get_flowinfo(gInetSocketAddress); 165 } 166 167 /** 168 * Gets @address's port. 169 * 170 * Return: the port for @address 171 * 172 * Since: 2.22 173 */ 174 public ushort getPort() 175 { 176 return g_inet_socket_address_get_port(gInetSocketAddress); 177 } 178 179 /** 180 * Gets the `sin6_scope_id` field from @address, 181 * which must be an IPv6 address. 182 * 183 * Return: the scope id field 184 * 185 * Since: 2.32 186 */ 187 public uint getScopeId() 188 { 189 return g_inet_socket_address_get_scope_id(gInetSocketAddress); 190 } 191 }