[asycxx-devel] SF.net SVN: asycxx:[14] trunk
Status: Alpha
Brought to you by:
joe_steeve
From: <joe...@us...> - 2009-03-12 12:58:06
|
Revision: 14 http://asycxx.svn.sourceforge.net/asycxx/?rev=14&view=rev Author: joe_steeve Date: 2009-03-12 12:57:59 +0000 (Thu, 12 Mar 2009) Log Message: ----------- [ticket:2] A simple EchoServer example The echo-server simply echos back whatever we give. Demonstrates on using asycxx. From: Joe Steeve <js...@hi...> Modified Paths: -------------- trunk/Makefile.am trunk/configure.ac Added Paths: ----------- trunk/examples/ trunk/examples/Makefile.am trunk/examples/echoserver/ trunk/examples/echoserver/EchoServer.cxx trunk/examples/echoserver/Makefile.am Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-03-12 12:56:40 UTC (rev 13) +++ trunk/Makefile.am 2009-03-12 12:57:59 UTC (rev 14) @@ -1,5 +1,5 @@ # -*- mode: makefile; indent-tabs-mode: nil; tab-width: 4; -*- -SUBDIRS = src include +SUBDIRS = src include examples pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = asycxx-0.1.pc Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-03-12 12:56:40 UTC (rev 13) +++ trunk/configure.ac 2009-03-12 12:57:59 UTC (rev 14) @@ -68,6 +68,8 @@ Makefile src/Makefile include/Makefile +examples/Makefile +examples/echoserver/Makefile asycxx-0.1.pc ]) AC_CONFIG_LINKS(src/Logger.h:include/asycxx/Logger.h Added: trunk/examples/Makefile.am =================================================================== --- trunk/examples/Makefile.am (rev 0) +++ trunk/examples/Makefile.am 2009-03-12 12:57:59 UTC (rev 14) @@ -0,0 +1,2 @@ + +SUBDIRS = echoserver Added: trunk/examples/echoserver/EchoServer.cxx =================================================================== --- trunk/examples/echoserver/EchoServer.cxx (rev 0) +++ trunk/examples/echoserver/EchoServer.cxx 2009-03-12 12:57:59 UTC (rev 14) @@ -0,0 +1,79 @@ + +/******************************************************************** + * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All + * rights reserved. + * + * This program and the accompanying materials are made available + * under the terms described in the LICENSE file which accompanies + * this distribution. If the LICENSE file was not attached to this + * distribution or for further clarifications, please contact + * le...@hi.... + * + *******************************************************************/ + +#include <memory> + +#include <asycxx/Logger.h> +#include <asycxx/Error.h> +#include <asycxx/Timer.h> +#include <asycxx/SelectReactor.h> +#include <asycxx/Protocol.h> +#include <asycxx/Factory.h> +#include <asycxx/TCPListener.h> + +Logger *Log; + +class EchoServerProtocol : public Protocol +{ +public: + EchoServerProtocol (Reactor *reactor, Factory *factory, Transport *transport) + : Protocol (reactor, factory, transport) + {} + ~EchoServerProtocol () {} + + void DataAvailable (DataBuffer *data) + { + m_Transport->Write (data); + } +}; + + +class EchoServerProtocolFactory : public Factory +{ +public: + EchoServerProtocolFactory (Reactor *reactor) : Factory (reactor) + {} + ~EchoServerProtocolFactory () {} + + EchoServerProtocol * GetProtocol (Transport *trans) + { + return new EchoServerProtocol (m_Reactor, this, trans); + } +}; + + +int +main () +{ + Reactor *reactor; + + Log = new Logger(); + Log->EnableConsole(); + + reactor = new SelectReactor (); + Timer::Init (reactor); + + EchoServerProtocolFactory echofactory (reactor); + TCPListener echolistener (reactor, &echofactory, (char *)"0.0.0.0", + 10000); + reactor->Run (); +} + +/* + Local Variables: + mode: c++ + indent-tabs-mode: nil + tab-width: 4 + c-file-style: "gnu" + End: +*/ Added: trunk/examples/echoserver/Makefile.am =================================================================== --- trunk/examples/echoserver/Makefile.am (rev 0) +++ trunk/examples/echoserver/Makefile.am 2009-03-12 12:57:59 UTC (rev 14) @@ -0,0 +1,14 @@ + +noinst_PROGRAMS = EchoServer + +EchoServer_SOURCES = EchoServer.cxx +EchoServer_LDADD = $(top_srcdir)/src/libasycxx-0.1.la +EchoServer_CPPFLAGS = -I$(top_srcdir)/include +EchoServer_LDFLAGS = -L$(top_srcdir)/src + + +# Local Variables: +# mode: makefile +# indent-tabs-mode: nil +# tab-width: 4 +# End: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |