/usr/include/giomm-2.4/giomm/socketlistener.h is in libglibmm-2.4-dev 2.32.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | // -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _GIOMM_SOCKETLISTENER_H
#define _GIOMM_SOCKETLISTENER_H
#include <glibmm/ustring.h>
#include <sigc++/sigc++.h>
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* Copyright (C) 2010 Jonathon Jongsma
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <glibmm/object.h>
#include <giomm/enums.h>
#include <giomm/socket.h>
#include <giomm/socketconnection.h>
#include <giomm/asyncresult.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GSocketListener GSocketListener;
typedef struct _GSocketListenerClass GSocketListenerClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
namespace Gio
{ class SocketListener_Class; } // namespace Gio
namespace Gio
{
/**
* Helper for accepting network client connections
*
* @see ThreadedSocketService, SocketService.
*
* A SocketListener is an object that keeps track of a set
* of server sockets and helps you accept sockets from any of the
* socket, either sync or async.
*
* If you want to implement a network server, also look at SocketService
* and ThreadedSocketService which are subclass of SocketListener
* that makes this even easier.
*
* @newin{2,24}
* @ingroup NetworkIO
*/
class SocketListener : public Glib::Object
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
public:
typedef SocketListener CppObjectType;
typedef SocketListener_Class CppClassType;
typedef GSocketListener BaseObjectType;
typedef GSocketListenerClass BaseClassType;
private: friend class SocketListener_Class;
static CppClassType socketlistener_class_;
private:
// noncopyable
SocketListener(const SocketListener&);
SocketListener& operator=(const SocketListener&);
protected:
explicit SocketListener(const Glib::ConstructParams& construct_params);
explicit SocketListener(GSocketListener* castitem);
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
public:
virtual ~SocketListener();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
static GType get_type() G_GNUC_CONST;
static GType get_base_type() G_GNUC_CONST;
#endif
///Provides access to the underlying C GObject.
GSocketListener* gobj() { return reinterpret_cast<GSocketListener*>(gobject_); }
///Provides access to the underlying C GObject.
const GSocketListener* gobj() const { return reinterpret_cast<GSocketListener*>(gobject_); }
///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
GSocketListener* gobj_copy();
private:
protected:
SocketListener();
public:
static Glib::RefPtr<SocketListener> create();
/** Sets the listen backlog on the sockets in the listener.
*
* See g_socket_set_listen_backlog() for details
*
* @newin{2,22}
* @param listen_backlog An integer.
*/
void set_backlog(int listen_backlog);
/** Adds @a socket to the set of sockets that we try to accept
* new clients from. The socket must be bound to a local
* address and listened to.
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* @newin{2,22}
* @param socket A listening Socket.
* @param source_object Optional Object identifying this source.
* @return <tt>true</tt> on success, <tt>false</tt> on error.
*/
bool add_socket(const Glib::RefPtr<Socket>& socket, const Glib::RefPtr<Glib::Object>& source_object);
//TODO: The use of WRAP_METHOD_DOCS_ONLY here is almost certainly not good enough.
//Check the HTML actually outputed and probably hand-code them as for Gio::File.
/** Adds @a socket to the set of sockets that we try to accept
* new clients from. The socket must be bound to a local
* address and listened to.
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* @newin{2,22}
* @param socket A listening Socket.
* @param source_object Optional Object identifying this source.
* @return <tt>true</tt> on success, <tt>false</tt> on error.
*/
bool add_socket(const Glib::RefPtr<Socket>& socket);
/** Creates a socket of type @a type and protocol @a protocol, binds
* it to @a address and adds it to the set of sockets we're accepting
* sockets from.
*
* Note that adding an IPv6 address, depending on the platform,
* may or may not result in a listener that also accepts IPv4
* connections. For more deterministic behavior, see
* g_socket_listener_add_inet_port().
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* If successful and @a effective_address is non-<tt>0</tt> then it will
* be set to the address that the binding actually occurred at. This
* is helpful for determining the port number that was used for when
* requesting a binding to port 0 (ie: "any port"). This address, if
* requested, belongs to the caller and must be freed.
*
* @newin{2,22}
* @param address A SocketAddress.
* @param type A SocketType.
* @param protocol A SocketProtocol.
* @param source_object Optional Object identifying this source.
* @param effective_address Location to store the address that was bound to, or <tt>0</tt>.
* @return <tt>true</tt> on success, <tt>false</tt> on error.
*/
bool add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type, SocketProtocol protocol, const Glib::RefPtr<Glib::Object>& source_object, Glib::RefPtr<SocketAddress>& effective_address);
/** Creates a socket of type @a type and protocol @a protocol, binds
* it to @a address and adds it to the set of sockets we're accepting
* sockets from.
*
* Note that adding an IPv6 address, depending on the platform,
* may or may not result in a listener that also accepts IPv4
* connections. For more deterministic behavior, see
* g_socket_listener_add_inet_port().
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* If successful and @a effective_address is non-<tt>0</tt> then it will
* be set to the address that the binding actually occurred at. This
* is helpful for determining the port number that was used for when
* requesting a binding to port 0 (ie: "any port"). This address, if
* requested, belongs to the caller and must be freed.
*
* @newin{2,22}
* @param address A SocketAddress.
* @param type A SocketType.
* @param protocol A SocketProtocol.
* @param source_object Optional Object identifying this source.
* @param effective_address Location to store the address that was bound to, or <tt>0</tt>.
* @return <tt>true</tt> on success, <tt>false</tt> on error.
*/
bool add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type, SocketProtocol protocol, Glib::RefPtr<SocketAddress>& effective_address);
/** Helper function for g_socket_listener_add_address() that
* creates a TCP/IP socket listening on IPv4 and IPv6 (if
* supported) on the specified port on all interfaces.
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* @newin{2,22}
* @param port An IP port number (non-zero).
* @param source_object Optional Object identifying this source.
* @return <tt>true</tt> on success, <tt>false</tt> on error.
*/
bool add_inet_port(guint16 port, const Glib::RefPtr<Glib::Object>& source_object);
/** Helper function for g_socket_listener_add_address() that
* creates a TCP/IP socket listening on IPv4 and IPv6 (if
* supported) on the specified port on all interfaces.
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* @newin{2,22}
* @param port An IP port number (non-zero).
* @param source_object Optional Object identifying this source.
* @return <tt>true</tt> on success, <tt>false</tt> on error.
*/
bool add_inet_port(guint16 port);
/** Listens for TCP connections on any available port number for both
* IPv6 and IPv4 (if each is available).
*
* This is useful if you need to have a socket for incoming connections
* but don't care about the specific port number.
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* @newin{2,24}
* @param source_object Optional Object identifying this source.
* @return The port number, or 0 in case of failure.
*/
guint16 add_any_inet_port(const Glib::RefPtr<Glib::Object>& source_object);
/** Listens for TCP connections on any available port number for both
* IPv6 and IPv4 (if each is available).
*
* This is useful if you need to have a socket for incoming connections
* but don't care about the specific port number.
*
* @a source_object will be passed out in the various calls
* to accept to identify this particular source, which is
* useful if you're listening on multiple addresses and do
* different things depending on what address is connected to.
*
* @newin{2,24}
* @param source_object Optional Object identifying this source.
* @return The port number, or 0 in case of failure.
*/
guint16 add_any_inet_port();
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns the Socket that was accepted.
*
* If you want to accept the high-level SocketConnection, not a Socket,
* which is often the case, then you should use g_socket_listener_accept()
* instead.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A Socket on success, <tt>0</tt> on error.
*/
Glib::RefPtr<Socket> accept_socket(Glib::RefPtr<Glib::Object>& source_object, const Glib::RefPtr<Cancellable>& cancellable);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns the Socket that was accepted.
*
* If you want to accept the high-level SocketConnection, not a Socket,
* which is often the case, then you should use g_socket_listener_accept()
* instead.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A Socket on success, <tt>0</tt> on error.
*/
Glib::RefPtr<Socket> accept_socket(Glib::RefPtr<Glib::Object>& source_object);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns the Socket that was accepted.
*
* If you want to accept the high-level SocketConnection, not a Socket,
* which is often the case, then you should use g_socket_listener_accept()
* instead.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A Socket on success, <tt>0</tt> on error.
*/
Glib::RefPtr<Socket> accept_socket(const Glib::RefPtr<Cancellable>& cancellable);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns the Socket that was accepted.
*
* If you want to accept the high-level SocketConnection, not a Socket,
* which is often the case, then you should use g_socket_listener_accept()
* instead.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A Socket on success, <tt>0</tt> on error.
*/
Glib::RefPtr<Socket> accept_socket();
/** This is the asynchronous version of g_socket_listener_accept_socket().
*
* When the operation is finished @a callback will be
* called. You can then call g_socket_listener_accept_socket_finish()
* to get the result of the operation.
*
* @newin{2,22}
* @param cancellable A Cancellable, or <tt>0</tt>.
* @param callback A AsyncReadyCallback.
* @param user_data User data for the callback.
*/
void accept_socket_async(const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot);
/** This is the asynchronous version of g_socket_listener_accept_socket().
*
* When the operation is finished @a callback will be
* called. You can then call g_socket_listener_accept_socket_finish()
* to get the result of the operation.
*
* @newin{2,22}
* @param cancellable A Cancellable, or <tt>0</tt>.
* @param callback A AsyncReadyCallback.
* @param user_data User data for the callback.
*/
void accept_socket_async(const SlotAsyncReady& slot);
/** Finishes an async accept operation. See g_socket_listener_accept_socket_async()
*
* @newin{2,22}
* @param result A AsyncResult.
* @param source_object Optional Object identifying this source.
* @return A Socket on success, <tt>0</tt> on error.
*/
Glib::RefPtr<Socket> accept_socket_finish(const Glib::RefPtr<AsyncResult>& result, Glib::RefPtr<Glib::Object>& source_object);
/** Finishes an async accept operation. See g_socket_listener_accept_socket_async()
*
* @newin{2,22}
* @param result A AsyncResult.
* @param source_object Optional Object identifying this source.
* @return A Socket on success, <tt>0</tt> on error.
*/
Glib::RefPtr<Socket> accept_socket_finish(const Glib::RefPtr<AsyncResult>& result);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns a SocketConnection for the socket that was
* accepted.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A SocketConnection on success, <tt>0</tt> on error.
*/
Glib::RefPtr<SocketConnection> accept(Glib::RefPtr<Object>& source_object, const Glib::RefPtr<Cancellable>& cancellable);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns a SocketConnection for the socket that was
* accepted.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A SocketConnection on success, <tt>0</tt> on error.
*/
Glib::RefPtr<SocketConnection> accept(Glib::RefPtr<Object>& source_object);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns a SocketConnection for the socket that was
* accepted.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A SocketConnection on success, <tt>0</tt> on error.
*/
Glib::RefPtr<SocketConnection> accept(const Glib::RefPtr<Cancellable>& cancellable);
/** Blocks waiting for a client to connect to any of the sockets added
* to the listener. Returns a SocketConnection for the socket that was
* accepted.
*
* If @a source_object is not <tt>0</tt> it will be filled out with the source
* object specified when the corresponding socket or address was added
* to the listener.
*
* If @a cancellable is not <tt>0</tt>, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error IO_ERROR_CANCELLED will be returned.
*
* @newin{2,22}
* @param source_object Location where Object pointer will be stored, or <tt>0</tt>.
* @param cancellable Optional Cancellable object, <tt>0</tt> to ignore.
* @return A SocketConnection on success, <tt>0</tt> on error.
*/
Glib::RefPtr<SocketConnection> accept();
/** This is the asynchronous version of g_socket_listener_accept().
*
* When the operation is finished @a callback will be
* called. You can then call g_socket_listener_accept_socket()
* to get the result of the operation.
*
* @newin{2,22}
* @param cancellable A Cancellable, or <tt>0</tt>.
* @param callback A AsyncReadyCallback.
* @param user_data User data for the callback.
*/
void accept_async(const SlotAsyncReady& slot);
/** This is the asynchronous version of g_socket_listener_accept().
*
* When the operation is finished @a callback will be
* called. You can then call g_socket_listener_accept_socket()
* to get the result of the operation.
*
* @newin{2,22}
* @param cancellable A Cancellable, or <tt>0</tt>.
* @param callback A AsyncReadyCallback.
* @param user_data User data for the callback.
*/
void accept_async(const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot);
/** Finishes an async accept operation. See g_socket_listener_accept_async()
*
* @newin{2,22}
* @param result A AsyncResult.
* @param source_object Optional Object identifying this source.
* @return A SocketConnection on success, <tt>0</tt> on error.
*/
Glib::RefPtr<SocketConnection> accept_finish(const Glib::RefPtr<AsyncResult>& result, Glib::RefPtr<Glib::Object>& source_object);
/** Finishes an async accept operation. See g_socket_listener_accept_async()
*
* @newin{2,22}
* @param result A AsyncResult.
* @param source_object Optional Object identifying this source.
* @return A SocketConnection on success, <tt>0</tt> on error.
*/
Glib::RefPtr<SocketConnection> accept_finish(const Glib::RefPtr<AsyncResult>& result);
/** Closes all the sockets in the listener.
*
* @newin{2,22}
*/
void close();
#ifdef GLIBMM_PROPERTIES_ENABLED
/** outstanding connections in the listen queue.
*
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
* the value of the property changes.
*/
Glib::PropertyProxy< int > property_listen_backlog() ;
#endif //#GLIBMM_PROPERTIES_ENABLED
#ifdef GLIBMM_PROPERTIES_ENABLED
/** outstanding connections in the listen queue.
*
* You rarely need to use properties because there are get_ and set_ methods for almost all of them.
* @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
* the value of the property changes.
*/
Glib::PropertyProxy_ReadOnly< int > property_listen_backlog() const;
#endif //#GLIBMM_PROPERTIES_ENABLED
public:
public:
//C++ methods used to invoke GTK+ virtual functions:
protected:
//GTK+ Virtual Functions (override these to change behaviour):
//Default Signal Handlers::
};
} // namespace Gio
namespace Glib
{
/** A Glib::wrap() method for this object.
*
* @param object The C instance.
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
* @result A C++ instance that wraps this C instance.
*
* @relates Gio::SocketListener
*/
Glib::RefPtr<Gio::SocketListener> wrap(GSocketListener* object, bool take_copy = false);
}
#endif /* _GIOMM_SOCKETLISTENER_H */
|