/*] Copyright (c) 2009-2010, Charles McGarvey [************************** **] All rights reserved. * * vi:ts=4 sw=4 tw=75 * * Distributable under the terms and conditions of the 2-clause BSD license; * see the file COPYING for a complete text of the license. * **************************************************************************/ /** * \file Service.hh * Classes for publishing and finding network services. */ #ifndef _MOOF_SERVICE_HH_ #define _MOOF_SERVICE_HH_ #include #include #include namespace Mf { /** * Class representing a network service. */ class Service { public: /** * Construct a network service. * \param address The address of the host. * \param text The service information. */ Service(const SocketAddress& address, const std::string& text); /** * Publish the service on the local network. */ void publish(); void stop(); /** * Get the host address. * \return The address. */ const SocketAddress& address() const { return mAddress; } /** * Get the service information. * \return The service information as a string. */ const std::string& text() const { return mText; } private: int handlePacket(SocketMultiplexer& sock, Packet& packet, const SocketAddress& address); SocketAddress mAddress; std::string mText; }; class ServiceFinder { public: ServiceFinder(const std::string& service, int type = SOCK_STREAM); const std::vector& services() const { return mServices; } private: int handlePacket(SocketMultiplexer& sock, Packet& packet, const SocketAddress& address); std::string mService; std::vector mServices; }; } // namespace Mf #endif // _MOOF_SERVICE_HH_