diff options
author | Jonathon Jongsma <jonathon@quotidian.org> | 2010-01-02 22:30:05 -0600 |
---|---|---|
committer | Jonathon Jongsma <jonathon@quotidian.org> | 2010-01-02 22:30:05 -0600 |
commit | e01f426be87c60367f4362064f6b96277c6cdd9c (patch) | |
tree | 926686d3f1a03a6aac8ccbf5201648ed94a31117 /gio | |
parent | 9fbd1dc96fd3e84f3b66c3718d943b96b2300877 (diff) | |
download | glibmm-e01f426be87c60367f4362064f6b96277c6cdd9c.tar.gz |
Wrap SocketService
Diffstat (limited to 'gio')
-rw-r--r-- | gio/src/filelist.am | 1 | ||||
-rw-r--r-- | gio/src/socketservice.ccg | 24 | ||||
-rw-r--r-- | gio/src/socketservice.hg | 80 |
3 files changed, 105 insertions, 0 deletions
diff --git a/gio/src/filelist.am b/gio/src/filelist.am index c791d453..9ceb12b7 100644 --- a/gio/src/filelist.am +++ b/gio/src/filelist.am @@ -59,6 +59,7 @@ giomm_files_any_hg = \ socketconnectable.hg \ socketconnection.hg \ socketlistener.hg \ + socketservice.hg \ srvtarget.hg \ tcpconnection.hg \ themedicon.hg \ diff --git a/gio/src/socketservice.ccg b/gio/src/socketservice.ccg new file mode 100644 index 00000000..6e077695 --- /dev/null +++ b/gio/src/socketservice.ccg @@ -0,0 +1,24 @@ +// -*- 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 <gio/gio.h> + +namespace Gio +{ +} // namespace Gio diff --git a/gio/src/socketservice.hg b/gio/src/socketservice.hg new file mode 100644 index 00000000..a6a737be --- /dev/null +++ b/gio/src/socketservice.hg @@ -0,0 +1,80 @@ +// -*- 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 <giomm/socketlistener.h> + +_DEFS(giomm,gio) +_PINCLUDE(giomm/private/socketlistener_p.h) + +namespace Gio +{ + +/** @defgroup NetworkIO Portable Network I/O Functionality + */ + +/** + * Make it easy to implement a network service + * + * @see ThreadedSocketService, SocketListener. + * + * A SocketService is an object that represents a service that is + * provided to the network or over local sockets. When a new + * connection is made to the service the SocketService:incoming + * signal is emitted. + * + * A SocketService is a subclass of SocketListener and you need + * to add the addresses you want to accept connections on to the + * with the SocketListener APIs. + * + * There are two options for implementing a network service based on + * SocketService. The first is to create the service using + * g_socket_service_new() and to connect to the SocketService:incoming + * signal. The second is to subclass SocketService and override the + * default signal handler implementation. + * + * In either case, the handler must immediately return, or else it + * will block additional incoming connections from being serviced. + * If you are interested in writing connection handlers that contain + * blocking code then see ThreadedSocketService. + * + * The socket service runs on the main loop in the main thread, and is + * not threadsafe in general. However, the calls to start and stop + * the service are threadsafe so these can be used from threads that + * handle incoming clients. + * + * @newin{2,24} + * @ingroup NetworkIO + */ +class SocketService : public Gio::SocketListener +{ + _CLASS_GOBJECT(SocketService, GSocketService, G_SOCKET_SERVICE, Gio::SocketListener, GSocketListener) + +protected: + _CTOR_DEFAULT + +public: + _WRAP_CREATE() + _WRAP_METHOD(void start(), g_socket_service_start) + _WRAP_METHOD(void stop(), g_socket_service_stop) + _WRAP_METHOD(bool is_active(), g_socket_service_is_active) + + _WRAP_SIGNAL(bool incoming(const Glib::RefPtr<SocketConnection>& connection, const Glib::RefPtr<Glib::Object>& source_object), "incoming") +}; + +} // namespace Gio |