X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Examples%2FUDPClientServer%2FudpServer.cc;h=fbc16e4b89b4c664d8201191502ceedc13538f24;hb=34700cdc907e04dbe026df9e86d0509990706a31;hp=7865e62dae9691b2d8b3db2ca8fd8daf88848582;hpb=ea8b2923c29a6902f507db2b485a44a58e9406f0;p=senf.git diff --git a/Examples/UDPClientServer/udpServer.cc b/Examples/UDPClientServer/udpServer.cc index 7865e62..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,22 +29,23 @@ 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(); + event.enable(); + senf::scheduler::process(); } private: - void readFromClient(senf::Scheduler::EventId event) + void readFromClient(int event) { std::string data (serverSock.read()); std::cout << "> " << data<