X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Examples%2FUDPClientServer%2FMainpage.dox;h=49043d8c1578f666edbd8f47c1f2a38cb7552b51;hb=ff4249b4a9c23236b2e56dcd593c91a5c58f7b75;hp=b35b64293b4fb7cbd6fd715d5c57fb274f317e3f;hpb=ea8b2923c29a6902f507db2b485a44a58e9406f0;p=senf.git diff --git a/Examples/UDPClientServer/Mainpage.dox b/Examples/UDPClientServer/Mainpage.dox index b35b642..49043d8 100644 --- a/Examples/UDPClientServer/Mainpage.dox +++ b/Examples/UDPClientServer/Mainpage.dox @@ -1,8 +1,8 @@ -// $Id: Mainpage.dox 625 2008-01-16 12:00:00Z Pug $ +// $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// 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 @@ -20,38 +20,38 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/** \mainpage UDP Client/Server example application +/** \mainpage UDP Client/Server example application \dontinclude udpServer.cc This Application is a command line based client/server application, which sends some strings from client to server, where they are printed on the command line. - After installing the Library, the udpServer and the udpClient can be found in the - senf/Example/udpServer directory and compiled with + After installing the Library, the udpServer and the udpClient can be found in the + senf/Example/udpServer directory and compiled with
-        #scons -u
+        # scons -u
         
 
-        #./udpServer
-        #./udpClient
+        # ./udpServer
+        # ./udpClient
     
- When we take a look to the code, we start with the Server: - First we include the necessary headers: + When we take a look to the code, we start with the Server: + First we include the necessary headers: \skip // Custom includes \until membind - The Scheduler will be needed because we implement a non blocking UDP Server with the %senf - integrated Scheduler. The scheduler library provides a simple yet flexible abstraction of + The Scheduler will be needed because we implement a non blocking UDP Server with the %senf + integrated Scheduler. The scheduler library provides a simple yet flexible abstraction of the standard asynchronous UNIX mainloop utilizing \c select or \c poll. \section UDP_serverApplication UDP server application First we define a class which is responsible for opening a socket and print out the incoming - data on stdout. We create a \c UDPv4ClientSocketHandle, which is an unconnected and + data on stdout. We create a \c ::UDPv4ClientSocketHandle, which is an unconnected and uninitialized UDP (Ipv4) socket. \until serverSock; @@ -61,26 +61,26 @@ \until {} - The public \c run() member is called to run the sniffer. It first adds the socket to the - Scheduler. The \c add() call takes two Arguments, the socket to bind to (which can be a - lot of things and must not necessarily be a socket instance) and callback function to call, - whenever there is an event on that socket.The callback is specified as a - Boost.Function object. A third - argument may be specified to restrict the events, on which the function is called, here we + The public \c run() member is called to run the sniffer. It first adds the socket to the + Scheduler. The \link senf::Scheduler::add add() \endlink call takes two Arguments, + the socket to bind to (which can be a lot of things and must not necessarily be a socket + instance) and callback function to call, whenever there is an event on that socket.The callback + is specified as a Boost.Function object. + A third argument may be specified to restrict the events, on which the function is called, here we used the EV_READ Argument, because we just want the program to read from the socket. The default argument is set to \c senf::Scheduler::EV_ALL, which allows all actions on the socket. \until } - Calling the Schedulers \c process() method will start the event loop. This call does not - return (ok, it does return in special cases if \c senf::Scheduler::terminate() is called which - does not apply here). The Callback Function is the \c readFromClient() Function, which is - declared as private here and will be called whenever an event on the socket is encountered. - The scheduler passes the event ID to the function. + Calling the Schedulers \link senf::Scheduler::process process()\endlink method will + start the event loop. This call does not return (ok, it does return in special cases if + \c senf::Scheduler::terminate() is called which does not apply here). The Callback Function is + the \c readFromClient() Function, which is declared as private here and will be called whenever + an event on the socket is encountered. The scheduler passes the event ID to the function. \until event) - In the function the data from the socket is put into a standard string and dumped out on stdout. + In the function the data from the socket is put into a standard string and dumped out on stdout. \until }; @@ -88,31 +88,31 @@ \until return 0; - That's it. We finish of by catching the exception and giving as much detail as possible if an + That's it. We finish of by catching the exception and giving as much %detail as possible if an exception is caught. The \c prettyName function from the \c Utils library is used, to get a nice, - printable representation of the dynamic type of the exception instance. It is an interface to - the g++ demangler. This is necessary since the name member of the C++ \c type_info instance is + printable representation of the dynamic type of the exception instance. It is an interface to + the g++ demangler. This is necessary since the name member of the C++ \c type_info instance is a mangled name in g++. \section UDP_clientApplication UDP client application - + \dontinclude udpClient.cc - The client application uses the same mechanisms, but implements them in a small main function. - It sends numbers as strings to the server. + The client application uses the same mechanisms, but implements them in a small main function. + It sends numbers as strings to the server. \skip argv[]) \until return 0; - First a \c UDPv4ClientSocketHandle is created. With the function + First a \c ::UDPv4ClientSocketHandle is created. With the function \c writeto(senf::INet4SocketAddress, string) the string s will be written to the specified - address and port, which is constructed here from a static string \c "127.0.0.1:4243". In this - example Integers from zero to ten are send to the Server socket. + address and port, which is constructed here from a static string read from the console with the format \c IP:PORT. In this + example Integers from zero to ten are send to the Server socket. The exception handling is again the same as with the server application. */ - + // Local Variables: // mode: c++ // fill-column: 100