X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Examples%2FUDPClientServer%2FudpServer.cc;h=fbc16e4b89b4c664d8201191502ceedc13538f24;hb=34700cdc907e04dbe026df9e86d0509990706a31;hp=e179f2fc1abb57278a71d2e61bc39b706849aac9;hpb=46d5597d4f410770852fe0494f9846b1dbaa24c9;p=senf.git diff --git a/Examples/UDPClientServer/udpServer.cc b/Examples/UDPClientServer/udpServer.cc index e179f2f..fbc16e4 100644 --- a/Examples/UDPClientServer/udpServer.cc +++ b/Examples/UDPClientServer/udpServer.cc @@ -1,3 +1,25 @@ +// $Id$ +// +// Copyright (C) 2008 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + // Custom includes #include #include @@ -7,36 +29,49 @@ class Server { senf::UDPv4ClientSocketHandle serverSock; + senf::scheduler::FdEvent event; public: Server(senf::INet4Address const & host, unsigned int port) - : serverSock(senf::INet4SocketAddress(host, port)) {} + : serverSock(senf::INet4SocketAddress(host, port)), + event("UDPv4ClientServer", senf::membind(&Server::readFromClient, this), + serverSock, senf::scheduler::FdEvent::EV_READ, false) + {} - void run() - { - senf::Scheduler::instance().add(serverSock, senf::membind(&Server::readFromClient, this), senf::Scheduler::EV_READ); - senf::Scheduler::instance().process(); - } + void run() + { + event.enable(); + senf::scheduler::process(); + } private: - void readFromClient(senf::Scheduler::EventId event) - { - std::string data (serverSock.read()); - std::cout << "> " << data< " << data<