| 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 = GSocketListener.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = SocketListener |
|---|
| 29 |
* strct = GSocketListener |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = SocketListener |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_socket_listener_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - glib.ErrorG |
|---|
| 47 |
* - glib.GException |
|---|
| 48 |
* - gio.AsyncResultIF |
|---|
| 49 |
* - gio.Cancellable |
|---|
| 50 |
* - gio.Socket |
|---|
| 51 |
* - gio.SocketAddress |
|---|
| 52 |
* - gio.SocketConnection |
|---|
| 53 |
* structWrap: |
|---|
| 54 |
* - GAsyncResult* -> AsyncResultIF |
|---|
| 55 |
* - GCancellable* -> Cancellable |
|---|
| 56 |
* - GObject* -> ObjectG |
|---|
| 57 |
* - GSocket* -> Socket |
|---|
| 58 |
* - GSocketAddress* -> SocketAddress |
|---|
| 59 |
* - GSocketConnection* -> SocketConnection |
|---|
| 60 |
* module aliases: |
|---|
| 61 |
* local aliases: |
|---|
| 62 |
* overrides: |
|---|
| 63 |
*/ |
|---|
| 64 |
|
|---|
| 65 |
module gio.SocketListener; |
|---|
| 66 |
|
|---|
| 67 |
public import gtkc.giotypes; |
|---|
| 68 |
|
|---|
| 69 |
private import gtkc.gio; |
|---|
| 70 |
private import glib.ConstructionException; |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
private import glib.ErrorG; |
|---|
| 74 |
private import glib.GException; |
|---|
| 75 |
private import gio.AsyncResultIF; |
|---|
| 76 |
private import gio.Cancellable; |
|---|
| 77 |
private import gio.Socket; |
|---|
| 78 |
private import gio.SocketAddress; |
|---|
| 79 |
private import gio.SocketConnection; |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
private import gobject.ObjectG; |
|---|
| 84 |
|
|---|
| 85 |
/** |
|---|
| 86 |
* Description |
|---|
| 87 |
* A GSocketListener is an object that keeps track of a set |
|---|
| 88 |
* of server sockets and helps you accept sockets from any of the |
|---|
| 89 |
* socket, either sync or async. |
|---|
| 90 |
* If you want to implement a network server, also look at GSocketService |
|---|
| 91 |
* and GThreadedSocketService which are subclass of GSocketListener |
|---|
| 92 |
* that makes this even easier. |
|---|
| 93 |
*/ |
|---|
| 94 |
public class SocketListener : ObjectG |
|---|
| 95 |
{ |
|---|
| 96 |
|
|---|
| 97 |
/** the main Gtk struct */ |
|---|
| 98 |
protected GSocketListener* gSocketListener; |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
public GSocketListener* getSocketListenerStruct() |
|---|
| 102 |
{ |
|---|
| 103 |
return gSocketListener; |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
/** the main Gtk struct as a void* */ |
|---|
| 108 |
protected override void* getStruct() |
|---|
| 109 |
{ |
|---|
| 110 |
return cast(void*)gSocketListener; |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
/** |
|---|
| 114 |
* Sets our main struct and passes it to the parent class |
|---|
| 115 |
*/ |
|---|
| 116 |
public this (GSocketListener* gSocketListener) |
|---|
| 117 |
{ |
|---|
| 118 |
if(gSocketListener is null) |
|---|
| 119 |
{ |
|---|
| 120 |
this = null; |
|---|
| 121 |
return; |
|---|
| 122 |
} |
|---|
| 123 |
//Check if there already is a D object for this gtk struct |
|---|
| 124 |
void* ptr = getDObject(cast(GObject*)gSocketListener); |
|---|
| 125 |
if( ptr !is null ) |
|---|
| 126 |
{ |
|---|
| 127 |
this = cast(SocketListener)ptr; |
|---|
| 128 |
return; |
|---|
| 129 |
} |
|---|
| 130 |
super(cast(GObject*)gSocketListener); |
|---|
| 131 |
this.gSocketListener = gSocketListener; |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
protected override void setStruct(GObject* obj) |
|---|
| 135 |
{ |
|---|
| 136 |
super.setStruct(obj); |
|---|
| 137 |
gSocketListener = cast(GSocketListener*)obj; |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
/** |
|---|
| 141 |
*/ |
|---|
| 142 |
|
|---|
| 143 |
/** |
|---|
| 144 |
* Creates a new GSocketListener with no sockets to listen for. |
|---|
| 145 |
* New listeners can be added with e.g. g_socket_listener_add_address() |
|---|
| 146 |
* or g_socket_listener_add_inet_port(). |
|---|
| 147 |
* Since 2.22 |
|---|
| 148 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 149 |
*/ |
|---|
| 150 |
public this () |
|---|
| 151 |
{ |
|---|
| 152 |
// GSocketListener * g_socket_listener_new (void); |
|---|
| 153 |
auto p = g_socket_listener_new(); |
|---|
| 154 |
if(p is null) |
|---|
| 155 |
{ |
|---|
| 156 |
throw new ConstructionException("null returned by g_socket_listener_new()"); |
|---|
| 157 |
} |
|---|
| 158 |
this(cast(GSocketListener*) p); |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
/** |
|---|
| 162 |
* Adds socket to the set of sockets that we try to accept |
|---|
| 163 |
* new clients from. The socket must be bound to a local |
|---|
| 164 |
* address and listened to. |
|---|
| 165 |
* source_object will be passed out in the various calls |
|---|
| 166 |
* to accept to identify this particular source, which is |
|---|
| 167 |
* useful if you're listening on multiple addresses and do |
|---|
| 168 |
* different things depending on what address is connected to. |
|---|
| 169 |
* Since 2.22 |
|---|
| 170 |
* Params: |
|---|
| 171 |
* socket = a listening GSocket |
|---|
| 172 |
* sourceObject = Optional GObject identifying this source. [allow-none] |
|---|
| 173 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 174 |
* Throws: GException on failure. |
|---|
| 175 |
*/ |
|---|
| 176 |
public int addSocket(Socket socket, ObjectG sourceObject) |
|---|
| 177 |
{ |
|---|
| 178 |
// gboolean g_socket_listener_add_socket (GSocketListener *listener, GSocket *socket, GObject *source_object, GError **error); |
|---|
| 179 |
GError* err = null; |
|---|
| 180 |
|
|---|
| 181 |
auto p = g_socket_listener_add_socket(gSocketListener, (socket is null) ? null : socket.getSocketStruct(), (sourceObject is null) ? null : sourceObject.getObjectGStruct(), &err); |
|---|
| 182 |
|
|---|
| 183 |
if (err !is null) |
|---|
| 184 |
{ |
|---|
| 185 |
throw new GException( new ErrorG(err) ); |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
return p; |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
/** |
|---|
| 192 |
* Creates a socket of type type and protocol protocol, binds |
|---|
| 193 |
* it to address and adds it to the set of sockets we're accepting |
|---|
| 194 |
* sockets from. |
|---|
| 195 |
* Note that adding an IPv6 address, depending on the platform, |
|---|
| 196 |
* may or may not result in a listener that also accepts IPv4 |
|---|
| 197 |
* connections. For more determinstic behaviour, see |
|---|
| 198 |
* g_socket_listener_add_inet_port(). |
|---|
| 199 |
* source_object will be passed out in the various calls |
|---|
| 200 |
* to accept to identify this particular source, which is |
|---|
| 201 |
* useful if you're listening on multiple addresses and do |
|---|
| 202 |
* different things depending on what address is connected to. |
|---|
| 203 |
* If successful and effective_address is non-NULL then it will |
|---|
| 204 |
* be set to the address that the binding actually occured at. This |
|---|
| 205 |
* is helpful for determining the port number that was used for when |
|---|
| 206 |
* requesting a binding to port 0 (ie: "any port"). This address, if |
|---|
| 207 |
* requested, belongs to the caller and must be freed. |
|---|
| 208 |
* Since 2.22 |
|---|
| 209 |
* Params: |
|---|
| 210 |
* address = a GSocketAddress |
|---|
| 211 |
* type = a GSocketType |
|---|
| 212 |
* protocol = a GSocketProtocol |
|---|
| 213 |
* sourceObject = Optional GObject identifying this source. [allow-none] |
|---|
| 214 |
* effectiveAddress = location to store the address that was bound to, or NULL. [out][allow-none] |
|---|
| 215 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 216 |
* Throws: GException on failure. |
|---|
| 217 |
*/ |
|---|
| 218 |
public int addAddress(SocketAddress address, GSocketType type, GSocketProtocol protocol, ObjectG sourceObject, out SocketAddress effectiveAddress) |
|---|
| 219 |
{ |
|---|
| 220 |
// gboolean g_socket_listener_add_address (GSocketListener *listener, GSocketAddress *address, GSocketType type, GSocketProtocol protocol, GObject *source_object, GSocketAddress **effective_address, GError **error); |
|---|
| 221 |
GSocketAddress* outeffectiveAddress = null; |
|---|
| 222 |
GError* err = null; |
|---|
| 223 |
|
|---|
| 224 |
auto p = g_socket_listener_add_address(gSocketListener, (address is null) ? null : address.getSocketAddressStruct(), type, protocol, (sourceObject is null) ? null : sourceObject.getObjectGStruct(), &outeffectiveAddress, &err); |
|---|
| 225 |
|
|---|
| 226 |
if (err !is null) |
|---|
| 227 |
{ |
|---|
| 228 |
throw new GException( new ErrorG(err) ); |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
effectiveAddress = new SocketAddress(outeffectiveAddress); |
|---|
| 232 |
return p; |
|---|
| 233 |
} |
|---|
| 234 |
|
|---|
| 235 |
/** |
|---|
| 236 |
* Helper function for g_socket_listener_add_address() that |
|---|
| 237 |
* creates a TCP/IP socket listening on IPv4 and IPv6 (if |
|---|
| 238 |
* supported) on the specified port on all interfaces. |
|---|
| 239 |
* source_object will be passed out in the various calls |
|---|
| 240 |
* to accept to identify this particular source, which is |
|---|
| 241 |
* useful if you're listening on multiple addresses and do |
|---|
| 242 |
* different things depending on what address is connected to. |
|---|
| 243 |
* Since 2.22 |
|---|
| 244 |
* Params: |
|---|
| 245 |
* port = an IP port number (non-zero) |
|---|
| 246 |
* sourceObject = Optional GObject identifying this source. [allow-none] |
|---|
| 247 |
* Returns: TRUE on success, FALSE on error. |
|---|
| 248 |
* Throws: GException on failure. |
|---|
| 249 |
*/ |
|---|
| 250 |
public int addInetPort(ushort port, ObjectG sourceObject) |
|---|
| 251 |
{ |
|---|
| 252 |
// gboolean g_socket_listener_add_inet_port (GSocketListener *listener, guint16 port, GObject *source_object, GError **error); |
|---|
| 253 |
GError* err = null; |
|---|
| 254 |
|
|---|
| 255 |
auto p = g_socket_listener_add_inet_port(gSocketListener, port, (sourceObject is null) ? null : sourceObject.getObjectGStruct(), &err); |
|---|
| 256 |
|
|---|
| 257 |
if (err !is null) |
|---|
| 258 |
{ |
|---|
| 259 |
throw new GException( new ErrorG(err) ); |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
return p; |
|---|
| 263 |
} |
|---|
| 264 |
|
|---|
| 265 |
/** |
|---|
| 266 |
* Listens for TCP connections on any available port number for both |
|---|
| 267 |
* IPv6 and IPv4 (if each are available). |
|---|
| 268 |
* This is useful if you need to have a socket for incoming connections |
|---|
| 269 |
* but don't care about the specific port number. |
|---|
| 270 |
* source_object will be passed out in the various calls |
|---|
| 271 |
* to accept to identify this particular source, which is |
|---|
| 272 |
* useful if you're listening on multiple addresses and do |
|---|
| 273 |
* different things depending on what address is connected to. |
|---|
| 274 |
* Since 2.24 |
|---|
| 275 |
* Params: |
|---|
| 276 |
* sourceObject = Optional GObject identifying this source. [allow-none] |
|---|
| 277 |
* Returns: the port number, or 0 in case of failure. |
|---|
| 278 |
* Throws: GException on failure. |
|---|
| 279 |
*/ |
|---|
| 280 |
public ushort addAnyInetPort(ObjectG sourceObject) |
|---|
| 281 |
{ |
|---|
| 282 |
// guint16 g_socket_listener_add_any_inet_port (GSocketListener *listener, GObject *source_object, GError **error); |
|---|
| 283 |
GError* err = null; |
|---|
| 284 |
|
|---|
| 285 |
auto p = g_socket_listener_add_any_inet_port(gSocketListener, (sourceObject is null) ? null : sourceObject.getObjectGStruct(), &err); |
|---|
| 286 |
|
|---|
| 287 |
if (err !is null) |
|---|
| 288 |
{ |
|---|
| 289 |
throw new GException( new ErrorG(err) ); |
|---|
| 290 |
} |
|---|
| 291 |
|
|---|
| 292 |
return p; |
|---|
| 293 |
} |
|---|
| 294 |
|
|---|
| 295 |
/** |
|---|
| 296 |
* Blocks waiting for a client to connect to any of the sockets added |
|---|
| 297 |
* to the listener. Returns a GSocketConnection for the socket that was |
|---|
| 298 |
* accepted. |
|---|
| 299 |
* If source_object is not NULL it will be filled out with the source |
|---|
| 300 |
* object specified when the corresponding socket or address was added |
|---|
| 301 |
* to the listener. |
|---|
| 302 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 303 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 304 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 305 |
* Since 2.22 |
|---|
| 306 |
* Params: |
|---|
| 307 |
* sourceObject = location where GObject pointer will be stored, or NULL. [out][transfer none][allow-none] |
|---|
| 308 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 309 |
* Returns: a GSocketConnection on success, NULL on error. [transfer full] |
|---|
| 310 |
* Throws: GException on failure. |
|---|
| 311 |
*/ |
|---|
| 312 |
public SocketConnection accept(out ObjectG sourceObject, Cancellable cancellable) |
|---|
| 313 |
{ |
|---|
| 314 |
// GSocketConnection * g_socket_listener_accept (GSocketListener *listener, GObject **source_object, GCancellable *cancellable, GError **error); |
|---|
| 315 |
GObject* outsourceObject = null; |
|---|
| 316 |
GError* err = null; |
|---|
| 317 |
|
|---|
| 318 |
auto p = g_socket_listener_accept(gSocketListener, &outsourceObject, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 319 |
|
|---|
| 320 |
if (err !is null) |
|---|
| 321 |
{ |
|---|
| 322 |
throw new GException( new ErrorG(err) ); |
|---|
| 323 |
} |
|---|
| 324 |
|
|---|
| 325 |
sourceObject = new ObjectG(outsourceObject); |
|---|
| 326 |
if(p is null) |
|---|
| 327 |
{ |
|---|
| 328 |
return null; |
|---|
| 329 |
} |
|---|
| 330 |
return new SocketConnection(cast(GSocketConnection*) p); |
|---|
| 331 |
} |
|---|
| 332 |
|
|---|
| 333 |
/** |
|---|
| 334 |
* This is the asynchronous version of g_socket_listener_accept(). |
|---|
| 335 |
* When the operation is finished callback will be |
|---|
| 336 |
* called. You can then call g_socket_listener_accept_socket() |
|---|
| 337 |
* to get the result of the operation. |
|---|
| 338 |
* Since 2.22 |
|---|
| 339 |
* Params: |
|---|
| 340 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 341 |
* callback = a GAsyncReadyCallback. [scope async] |
|---|
| 342 |
* userData = user data for the callback. [closure] |
|---|
| 343 |
*/ |
|---|
| 344 |
public void acceptAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 345 |
{ |
|---|
| 346 |
// void g_socket_listener_accept_async (GSocketListener *listener, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 347 |
g_socket_listener_accept_async(gSocketListener, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 348 |
} |
|---|
| 349 |
|
|---|
| 350 |
/** |
|---|
| 351 |
* Finishes an async accept operation. See g_socket_listener_accept_async() |
|---|
| 352 |
* Since 2.22 |
|---|
| 353 |
* Params: |
|---|
| 354 |
* result = a GAsyncResult. |
|---|
| 355 |
* sourceObject = Optional GObject identifying this source. [out][transfer none][allow-none] |
|---|
| 356 |
* Returns: a GSocketConnection on success, NULL on error. [transfer full] |
|---|
| 357 |
* Throws: GException on failure. |
|---|
| 358 |
*/ |
|---|
| 359 |
public SocketConnection acceptFinish(AsyncResultIF result, ref ObjectG sourceObject) |
|---|
| 360 |
{ |
|---|
| 361 |
// GSocketConnection * g_socket_listener_accept_finish (GSocketListener *listener, GAsyncResult *result, GObject **source_object, GError **error); |
|---|
| 362 |
GObject* outsourceObject = (sourceObject is null) ? null : sourceObject.getObjectGStruct(); |
|---|
| 363 |
GError* err = null; |
|---|
| 364 |
|
|---|
| 365 |
auto p = g_socket_listener_accept_finish(gSocketListener, (result is null) ? null : result.getAsyncResultTStruct(), &outsourceObject, &err); |
|---|
| 366 |
|
|---|
| 367 |
if (err !is null) |
|---|
| 368 |
{ |
|---|
| 369 |
throw new GException( new ErrorG(err) ); |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
sourceObject = new ObjectG(outsourceObject); |
|---|
| 373 |
if(p is null) |
|---|
| 374 |
{ |
|---|
| 375 |
return null; |
|---|
| 376 |
} |
|---|
| 377 |
return new SocketConnection(cast(GSocketConnection*) p); |
|---|
| 378 |
} |
|---|
| 379 |
|
|---|
| 380 |
/** |
|---|
| 381 |
* Blocks waiting for a client to connect to any of the sockets added |
|---|
| 382 |
* to the listener. Returns the GSocket that was accepted. |
|---|
| 383 |
* If you want to accept the high-level GSocketConnection, not a GSocket, |
|---|
| 384 |
* which is often the case, then you should use g_socket_listener_accept() |
|---|
| 385 |
* instead. |
|---|
| 386 |
* If source_object is not NULL it will be filled out with the source |
|---|
| 387 |
* object specified when the corresponding socket or address was added |
|---|
| 388 |
* to the listener. |
|---|
| 389 |
* If cancellable is not NULL, then the operation can be cancelled by |
|---|
| 390 |
* triggering the cancellable object from another thread. If the operation |
|---|
| 391 |
* was cancelled, the error G_IO_ERROR_CANCELLED will be returned. |
|---|
| 392 |
* Since 2.22 |
|---|
| 393 |
* Params: |
|---|
| 394 |
* sourceObject = location where GObject pointer will be stored, or NULL. [out][transfer none][allow-none] |
|---|
| 395 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 396 |
* Returns: a GSocket on success, NULL on error. [transfer full] |
|---|
| 397 |
* Throws: GException on failure. |
|---|
| 398 |
*/ |
|---|
| 399 |
public Socket acceptSocket(out ObjectG sourceObject, Cancellable cancellable) |
|---|
| 400 |
{ |
|---|
| 401 |
// GSocket * g_socket_listener_accept_socket (GSocketListener *listener, GObject **source_object, GCancellable *cancellable, GError **error); |
|---|
| 402 |
GObject* outsourceObject = null; |
|---|
| 403 |
GError* err = null; |
|---|
| 404 |
|
|---|
| 405 |
auto p = g_socket_listener_accept_socket(gSocketListener, &outsourceObject, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 406 |
|
|---|
| 407 |
if (err !is null) |
|---|
| 408 |
{ |
|---|
| 409 |
throw new GException( new ErrorG(err) ); |
|---|
| 410 |
} |
|---|
| 411 |
|
|---|
| 412 |
sourceObject = new ObjectG(outsourceObject); |
|---|
| 413 |
if(p is null) |
|---|
| 414 |
{ |
|---|
| 415 |
return null; |
|---|
| 416 |
} |
|---|
| 417 |
return new Socket(cast(GSocket*) p); |
|---|
| 418 |
} |
|---|
| 419 |
|
|---|
| 420 |
/** |
|---|
| 421 |
* This is the asynchronous version of g_socket_listener_accept_socket(). |
|---|
| 422 |
* When the operation is finished callback will be |
|---|
| 423 |
* called. You can then call g_socket_listener_accept_socket_finish() |
|---|
| 424 |
* to get the result of the operation. |
|---|
| 425 |
* Since 2.22 |
|---|
| 426 |
* Params: |
|---|
| 427 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 428 |
* callback = a GAsyncReadyCallback. [scope async] |
|---|
| 429 |
* userData = user data for the callback. [closure] |
|---|
| 430 |
*/ |
|---|
| 431 |
public void acceptSocketAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 432 |
{ |
|---|
| 433 |
// void g_socket_listener_accept_socket_async (GSocketListener *listener, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 434 |
g_socket_listener_accept_socket_async(gSocketListener, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 435 |
} |
|---|
| 436 |
|
|---|
| 437 |
/** |
|---|
| 438 |
* Finishes an async accept operation. See g_socket_listener_accept_socket_async() |
|---|
| 439 |
* Since 2.22 |
|---|
| 440 |
* Params: |
|---|
| 441 |
* result = a GAsyncResult. |
|---|
| 442 |
* sourceObject = Optional GObject identifying this source. [out][transfer none][allow-none] |
|---|
| 443 |
* Returns: a GSocket on success, NULL on error. [transfer full] |
|---|
| 444 |
* Throws: GException on failure. |
|---|
| 445 |
*/ |
|---|
| 446 |
public Socket acceptSocketFinish(AsyncResultIF result, ref ObjectG sourceObject) |
|---|
| 447 |
{ |
|---|
| 448 |
// GSocket * g_socket_listener_accept_socket_finish (GSocketListener *listener, GAsyncResult *result, GObject **source_object, GError **error); |
|---|
| 449 |
GObject* outsourceObject = (sourceObject is null) ? null : sourceObject.getObjectGStruct(); |
|---|
| 450 |
GError* err = null; |
|---|
| 451 |
|
|---|
| 452 |
auto p = g_socket_listener_accept_socket_finish(gSocketListener, (result is null) ? null : result.getAsyncResultTStruct(), &outsourceObject, &err); |
|---|
| 453 |
|
|---|
| 454 |
if (err !is null) |
|---|
| 455 |
{ |
|---|
| 456 |
throw new GException( new ErrorG(err) ); |
|---|
| 457 |
} |
|---|
| 458 |
|
|---|
| 459 |
sourceObject = new ObjectG(outsourceObject); |
|---|
| 460 |
if(p is null) |
|---|
| 461 |
{ |
|---|
| 462 |
return null; |
|---|
| 463 |
} |
|---|
| 464 |
return new Socket(cast(GSocket*) p); |
|---|
| 465 |
} |
|---|
| 466 |
|
|---|
| 467 |
/** |
|---|
| 468 |
* Closes all the sockets in the listener. |
|---|
| 469 |
* Since 2.22 |
|---|
| 470 |
*/ |
|---|
| 471 |
public void close() |
|---|
| 472 |
{ |
|---|
| 473 |
// void g_socket_listener_close (GSocketListener *listener); |
|---|
| 474 |
g_socket_listener_close(gSocketListener); |
|---|
| 475 |
} |
|---|
| 476 |
|
|---|
| 477 |
/** |
|---|
| 478 |
* Sets the listen backlog on the sockets in the listener. |
|---|
| 479 |
* See g_socket_set_listen_backlog() for details |
|---|
| 480 |
* Since 2.22 |
|---|
| 481 |
* Params: |
|---|
| 482 |
* listenBacklog = an integer |
|---|
| 483 |
*/ |
|---|
| 484 |
public void setBacklog(int listenBacklog) |
|---|
| 485 |
{ |
|---|
| 486 |
// void g_socket_listener_set_backlog (GSocketListener *listener, int listen_backlog); |
|---|
| 487 |
g_socket_listener_set_backlog(gSocketListener, listenBacklog); |
|---|
| 488 |
} |
|---|
| 489 |
} |
|---|