diff options
55 files changed, 2760 insertions, 8 deletions
diff --git a/cpp/allDemos.py b/cpp/allDemos.py index ea797d3cda1..ef12c10db41 100755 --- a/cpp/allDemos.py +++ b/cpp/allDemos.py @@ -67,6 +67,7 @@ demos = [ "Ice/invoke", "Ice/latency", "Ice/minimal", + "Ice/multicast", "Ice/nested", "Ice/session", "Ice/throughput", diff --git a/cpp/demo/Ice/Makefile b/cpp/demo/Ice/Makefile index c797d57f744..c2ae6c733e8 100644 --- a/cpp/demo/Ice/Makefile +++ b/cpp/demo/Ice/Makefile @@ -22,7 +22,8 @@ SUBDIRS = minimal \ bidir \ session \ converter \ - async + async \ + multicast $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/demo/Ice/Makefile.mak b/cpp/demo/Ice/Makefile.mak index eebeb0e1cd0..d254a9d35e4 100644 --- a/cpp/demo/Ice/Makefile.mak +++ b/cpp/demo/Ice/Makefile.mak @@ -22,7 +22,8 @@ SUBDIRS = minimal \ bidir \ session \ converter \ - async + async \ + multicast !if "$(CPP_COMPILER)" != "BCC2006" && "$(CPP_COMPILER)" != "VC80_EXPRESS" SUBDIRS = $(SUBDIRS) MFC diff --git a/cpp/demo/Ice/README b/cpp/demo/Ice/README index 8ba5b6fa936..daf714a5d26 100644 --- a/cpp/demo/Ice/README +++ b/cpp/demo/Ice/README @@ -42,7 +42,11 @@ Demos in this directory: This demo illustrates a minimal Ice application. -- MFC +- multicast + + This demo illistrates the use of UDP multicast. + +- MFC (Windows Only) Shows how to use Ice in conjunction with the Microsoft Foundation Classes. diff --git a/cpp/demo/Ice/multicast/.depend b/cpp/demo/Ice/multicast/.depend new file mode 100644 index 00000000000..ffc9a6f097e --- /dev/null +++ b/cpp/demo/Ice/multicast/.depend @@ -0,0 +1,6 @@ +Hello$(OBJEXT): Hello.cpp ./Hello.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/InstanceF.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h +Client$(OBJEXT): Client.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/Proxy.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h ./Hello.h +HelloI$(OBJEXT): HelloI.cpp ../../../include/IceUtil/IceUtil.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/AbstractMutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/IceUtil/Algorithm.h ../../../include/IceUtil/ArgVector.h ../../../include/IceUtil/Base64.h ../../../include/IceUtil/Cache.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/CountDownLatch.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/IceUtil/CtrlCHandler.h ../../../include/IceUtil/Functional.h ../../../include/IceUtil/InputUtil.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/MD5.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Options.h ../../../include/IceUtil/RecMutex.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/OutputUtil.h ../../../include/IceUtil/RWRecMutex.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Random.h ../../../include/IceUtil/ScopedArray.h ../../../include/IceUtil/StaticMutex.h ../../../include/IceUtil/StringUtil.h ../../../include/IceUtil/UUID.h ../../../include/IceUtil/Unicode.h ../../../include/IceUtil/Timer.h ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/Ice/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Outgoing.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/OutgoingAsync.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h ./HelloI.h ./Hello.h +Server$(OBJEXT): Server.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/Proxy.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h ./HelloI.h ./Hello.h +Hello.cpp: Hello.ice +Hello.ice: $(SLICE2CPP) $(SLICEPARSERLIB) diff --git a/cpp/demo/Ice/multicast/.gitignore b/cpp/demo/Ice/multicast/.gitignore new file mode 100644 index 00000000000..9f5c1b1b66e --- /dev/null +++ b/cpp/demo/Ice/multicast/.gitignore @@ -0,0 +1,7 @@ +// Generated by makegitignore.py + +// IMPORTANT: Do not edit this file -- any edits made here will be lost! +client +server +Hello.cpp +Hello.h diff --git a/cpp/demo/Ice/multicast/Client.cpp b/cpp/demo/Ice/multicast/Client.cpp new file mode 100644 index 00000000000..be31247a8bb --- /dev/null +++ b/cpp/demo/Ice/multicast/Client.cpp @@ -0,0 +1,120 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <Hello.h> + +using namespace std; +using namespace Demo; + +class MulticastClient : public Ice::Application +{ +public: + + virtual int run(int, char*[]); + virtual void interruptCallback(int); + +private: + + void menu(); +}; + +int +main(int argc, char* argv[]) +{ + MulticastClient app; + return app.main(argc, argv, "config.client"); +} + +int +MulticastClient::run(int argc, char* argv[]) +{ + if(argc > 1) + { + cerr << appName() << ": too many arguments" << endl; + return EXIT_FAILURE; + } + + // + // Since this is an interactive demo we want the custom interrupt + // callback to be called when the process is interrupted. + // + callbackOnInterrupt(); + + HelloPrx proxy = HelloPrx::uncheckedCast(communicator()->propertyToProxy("Hello.Proxy")->ice_datagram()); + + menu(); + + char c; + do + { + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + proxy->sayHello(); + } + else if(c == 's') + { + proxy->shutdown(); + } + else if(c == 'x') + { + // Nothing to do + } + else if(c == '?') + { + menu(); + } + else + { + cout << "unknown command `" << c << "'" << endl; + menu(); + } + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + } + } + while(cin.good() && c != 'x'); + + return EXIT_SUCCESS; +} + +void +MulticastClient::interruptCallback(int) +{ + try + { + communicator()->destroy(); + } + catch(const IceUtil::Exception& ex) + { + cerr << appName() << ": " << ex << endl; + } + catch(...) + { + cerr << appName() << ": unknown exception" << endl; + } + exit(EXIT_SUCCESS); +} + +void +MulticastClient::menu() +{ + cout << + "usage:\n" + "t: send multicast message\n" + "s: shutdown server\n" + "x: exit\n" + "?: help\n"; +} diff --git a/cpp/demo/Ice/multicast/Hello.cpp b/cpp/demo/Ice/multicast/Hello.cpp new file mode 100644 index 00000000000..f1ade87c664 --- /dev/null +++ b/cpp/demo/Ice/multicast/Hello.cpp @@ -0,0 +1,477 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +// Ice version 3.3.0 +// Generated from file `Hello.ice' + +#include <Hello.h> +#include <Ice/LocalException.h> +#include <Ice/ObjectFactory.h> +#include <Ice/BasicStream.h> +#include <IceUtil/Iterator.h> +#include <IceUtil/ScopedArray.h> + +#ifndef ICE_IGNORE_VERSION +# if ICE_INT_VERSION / 100 != 303 +# error Ice version mismatch! +# endif +# if ICE_INT_VERSION % 100 > 50 +# error Beta header file detected +# endif +# if ICE_INT_VERSION % 100 < 0 +# error Ice patch level mismatch! +# endif +#endif + +static const ::std::string __Demo__Hello__sayHello_name = "sayHello"; + +static const ::std::string __Demo__Hello__shutdown_name = "shutdown"; + +::Ice::Object* IceInternal::upCast(::Demo::Hello* p) { return p; } +::IceProxy::Ice::Object* IceInternal::upCast(::IceProxy::Demo::Hello* p) { return p; } + +void +Demo::__read(::IceInternal::BasicStream* __is, ::Demo::HelloPrx& v) +{ + ::Ice::ObjectPrx proxy; + __is->read(proxy); + if(!proxy) + { + v = 0; + } + else + { + v = new ::IceProxy::Demo::Hello; + v->__copyFrom(proxy); + } +} + +void +IceProxy::Demo::Hello::sayHello(const ::Ice::Context* __ctx) +{ + int __cnt = 0; + while(true) + { + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase; + try + { + __delBase = __getDelegate(false); + ::IceDelegate::Demo::Hello* __del = dynamic_cast< ::IceDelegate::Demo::Hello*>(__delBase.get()); + __del->sayHello(__ctx); + return; + } + catch(const ::IceInternal::LocalExceptionWrapper& __ex) + { + __handleExceptionWrapperRelaxed(__delBase, __ex, __cnt); + } + catch(const ::Ice::LocalException& __ex) + { + __handleException(__delBase, __ex, __cnt); + } + } +} + +void +IceProxy::Demo::Hello::shutdown(const ::Ice::Context* __ctx) +{ + int __cnt = 0; + while(true) + { + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase; + try + { + __delBase = __getDelegate(false); + ::IceDelegate::Demo::Hello* __del = dynamic_cast< ::IceDelegate::Demo::Hello*>(__delBase.get()); + __del->shutdown(__ctx); + return; + } + catch(const ::IceInternal::LocalExceptionWrapper& __ex) + { + __handleExceptionWrapper(__delBase, __ex); + } + catch(const ::Ice::LocalException& __ex) + { + __handleException(__delBase, __ex, __cnt); + } + } +} + +const ::std::string& +IceProxy::Demo::Hello::ice_staticId() +{ + return ::Demo::Hello::ice_staticId(); +} + +::IceInternal::Handle< ::IceDelegateM::Ice::Object> +IceProxy::Demo::Hello::__createDelegateM() +{ + return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM::Demo::Hello); +} + +::IceInternal::Handle< ::IceDelegateD::Ice::Object> +IceProxy::Demo::Hello::__createDelegateD() +{ + return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::Demo::Hello); +} + +::IceProxy::Ice::Object* +IceProxy::Demo::Hello::__newInstance() const +{ + return new Hello; +} + +void +IceDelegateM::Demo::Hello::sayHello(const ::Ice::Context* __context) +{ + ::IceInternal::Outgoing __og(__handler.get(), __Demo__Hello__sayHello_name, ::Ice::Idempotent, __context); + bool __ok = __og.invoke(); + try + { + ::IceInternal::BasicStream* __is = __og.is(); + if(!__ok) + { + try + { + __is->throwException(); + } + catch(const ::Ice::UserException& __ex) + { + throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name()); + } + } + } + catch(const ::Ice::LocalException& __ex) + { + throw ::IceInternal::LocalExceptionWrapper(__ex, false); + } +} + +void +IceDelegateM::Demo::Hello::shutdown(const ::Ice::Context* __context) +{ + ::IceInternal::Outgoing __og(__handler.get(), __Demo__Hello__shutdown_name, ::Ice::Normal, __context); + bool __ok = __og.invoke(); + try + { + ::IceInternal::BasicStream* __is = __og.is(); + if(!__ok) + { + try + { + __is->throwException(); + } + catch(const ::Ice::UserException& __ex) + { + throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name()); + } + } + } + catch(const ::Ice::LocalException& __ex) + { + throw ::IceInternal::LocalExceptionWrapper(__ex, false); + } +} + +void +IceDelegateD::Demo::Hello::sayHello(const ::Ice::Context* __context) +{ + class _DirectI : public ::IceInternal::Direct + { + public: + + _DirectI(const ::Ice::Current& __current) : + ::IceInternal::Direct(__current) + { + } + + virtual ::Ice::DispatchStatus + run(::Ice::Object* object) + { + ::Demo::Hello* servant = dynamic_cast< ::Demo::Hello*>(object); + if(!servant) + { + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, _current.id, _current.facet, _current.operation); + } + servant->sayHello(_current); + return ::Ice::DispatchOK; + } + + private: + + }; + + ::Ice::Current __current; + __initCurrent(__current, __Demo__Hello__sayHello_name, ::Ice::Idempotent, __context); + try + { + _DirectI __direct(__current); + try + { + __direct.servant()->__collocDispatch(__direct); + } + catch(...) + { + __direct.destroy(); + throw; + } + __direct.destroy(); + } + catch(const ::Ice::SystemException&) + { + throw; + } + catch(const ::IceInternal::LocalExceptionWrapper&) + { + throw; + } + catch(const ::std::exception& __ex) + { + ::IceInternal::LocalExceptionWrapper::throwWrapper(__ex); + } + catch(...) + { + throw ::IceInternal::LocalExceptionWrapper(::Ice::UnknownException(__FILE__, __LINE__, "unknown c++ exception"), false); + } +} + +void +IceDelegateD::Demo::Hello::shutdown(const ::Ice::Context* __context) +{ + class _DirectI : public ::IceInternal::Direct + { + public: + + _DirectI(const ::Ice::Current& __current) : + ::IceInternal::Direct(__current) + { + } + + virtual ::Ice::DispatchStatus + run(::Ice::Object* object) + { + ::Demo::Hello* servant = dynamic_cast< ::Demo::Hello*>(object); + if(!servant) + { + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, _current.id, _current.facet, _current.operation); + } + servant->shutdown(_current); + return ::Ice::DispatchOK; + } + + private: + + }; + + ::Ice::Current __current; + __initCurrent(__current, __Demo__Hello__shutdown_name, ::Ice::Normal, __context); + try + { + _DirectI __direct(__current); + try + { + __direct.servant()->__collocDispatch(__direct); + } + catch(...) + { + __direct.destroy(); + throw; + } + __direct.destroy(); + } + catch(const ::Ice::SystemException&) + { + throw; + } + catch(const ::IceInternal::LocalExceptionWrapper&) + { + throw; + } + catch(const ::std::exception& __ex) + { + ::IceInternal::LocalExceptionWrapper::throwWrapper(__ex); + } + catch(...) + { + throw ::IceInternal::LocalExceptionWrapper(::Ice::UnknownException(__FILE__, __LINE__, "unknown c++ exception"), false); + } +} + +::Ice::ObjectPtr +Demo::Hello::ice_clone() const +{ + throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__); + return 0; // to avoid a warning with some compilers +} + +static const ::std::string __Demo__Hello_ids[2] = +{ + "::Demo::Hello", + "::Ice::Object" +}; + +bool +Demo::Hello::ice_isA(const ::std::string& _s, const ::Ice::Current&) const +{ + return ::std::binary_search(__Demo__Hello_ids, __Demo__Hello_ids + 2, _s); +} + +::std::vector< ::std::string> +Demo::Hello::ice_ids(const ::Ice::Current&) const +{ + return ::std::vector< ::std::string>(&__Demo__Hello_ids[0], &__Demo__Hello_ids[2]); +} + +const ::std::string& +Demo::Hello::ice_id(const ::Ice::Current&) const +{ + return __Demo__Hello_ids[0]; +} + +const ::std::string& +Demo::Hello::ice_staticId() +{ + return __Demo__Hello_ids[0]; +} + +::Ice::DispatchStatus +Demo::Hello::___sayHello(::IceInternal::Incoming&, const ::Ice::Current& __current) const +{ + __checkMode(::Ice::Idempotent, __current.mode); + sayHello(__current); + return ::Ice::DispatchOK; +} + +::Ice::DispatchStatus +Demo::Hello::___shutdown(::IceInternal::Incoming&, const ::Ice::Current& __current) +{ + __checkMode(::Ice::Normal, __current.mode); + shutdown(__current); + return ::Ice::DispatchOK; +} + +static ::std::string __Demo__Hello_all[] = +{ + "ice_id", + "ice_ids", + "ice_isA", + "ice_ping", + "sayHello", + "shutdown" +}; + +::Ice::DispatchStatus +Demo::Hello::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current) +{ + ::std::pair< ::std::string*, ::std::string*> r = ::std::equal_range(__Demo__Hello_all, __Demo__Hello_all + 6, current.operation); + if(r.first == r.second) + { + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation); + } + + switch(r.first - __Demo__Hello_all) + { + case 0: + { + return ___ice_id(in, current); + } + case 1: + { + return ___ice_ids(in, current); + } + case 2: + { + return ___ice_isA(in, current); + } + case 3: + { + return ___ice_ping(in, current); + } + case 4: + { + return ___sayHello(in, current); + } + case 5: + { + return ___shutdown(in, current); + } + } + + assert(false); + throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation); +} + +void +Demo::Hello::__write(::IceInternal::BasicStream* __os) const +{ + __os->writeTypeId(ice_staticId()); + __os->startWriteSlice(); + __os->endWriteSlice(); +#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + Object::__write(__os); +#else + ::Ice::Object::__write(__os); +#endif +} + +void +Demo::Hello::__read(::IceInternal::BasicStream* __is, bool __rid) +{ + if(__rid) + { + ::std::string myId; + __is->readTypeId(myId); + } + __is->startReadSlice(); + __is->endReadSlice(); +#if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + Object::__read(__is, true); +#else + ::Ice::Object::__read(__is, true); +#endif +} + +void +Demo::Hello::__write(const ::Ice::OutputStreamPtr&) const +{ + Ice::MarshalException ex(__FILE__, __LINE__); + ex.reason = "type Demo::Hello was not generated with stream support"; + throw ex; +} + +void +Demo::Hello::__read(const ::Ice::InputStreamPtr&, bool) +{ + Ice::MarshalException ex(__FILE__, __LINE__); + ex.reason = "type Demo::Hello was not generated with stream support"; + throw ex; +} + +void +Demo::__patch__HelloPtr(void* __addr, ::Ice::ObjectPtr& v) +{ + ::Demo::HelloPtr* p = static_cast< ::Demo::HelloPtr*>(__addr); + assert(p); + *p = ::Demo::HelloPtr::dynamicCast(v); + if(v && !*p) + { + IceInternal::Ex::throwUOE(::Demo::Hello::ice_staticId(), v->ice_id()); + } +} + +bool +Demo::operator==(const ::Demo::Hello& l, const ::Demo::Hello& r) +{ + return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r); +} + +bool +Demo::operator<(const ::Demo::Hello& l, const ::Demo::Hello& r) +{ + return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r); +} diff --git a/cpp/demo/Ice/multicast/Hello.h b/cpp/demo/Ice/multicast/Hello.h new file mode 100644 index 00000000000..30596b80879 --- /dev/null +++ b/cpp/demo/Ice/multicast/Hello.h @@ -0,0 +1,426 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +// Ice version 3.3.0 +// Generated from file `Hello.ice' + +#ifndef __Hello_h__ +#define __Hello_h__ + +#include <Ice/LocalObjectF.h> +#include <Ice/ProxyF.h> +#include <Ice/ObjectF.h> +#include <Ice/Exception.h> +#include <Ice/LocalObject.h> +#include <Ice/Proxy.h> +#include <Ice/Object.h> +#include <Ice/Outgoing.h> +#include <Ice/Incoming.h> +#include <Ice/Direct.h> +#include <Ice/StreamF.h> +#include <Ice/UndefSysMacros.h> + +#ifndef ICE_IGNORE_VERSION +# if ICE_INT_VERSION / 100 != 303 +# error Ice version mismatch! +# endif +# if ICE_INT_VERSION % 100 > 50 +# error Beta header file detected +# endif +# if ICE_INT_VERSION % 100 < 0 +# error Ice patch level mismatch! +# endif +#endif + +namespace IceProxy +{ + +namespace Demo +{ + +class Hello; + +} + +} + +namespace Demo +{ + +class Hello; +bool operator==(const Hello&, const Hello&); +bool operator<(const Hello&, const Hello&); + +} + +namespace IceInternal +{ + +::Ice::Object* upCast(::Demo::Hello*); +::IceProxy::Ice::Object* upCast(::IceProxy::Demo::Hello*); + +} + +namespace Demo +{ + +typedef ::IceInternal::Handle< ::Demo::Hello> HelloPtr; +typedef ::IceInternal::ProxyHandle< ::IceProxy::Demo::Hello> HelloPrx; + +void __read(::IceInternal::BasicStream*, HelloPrx&); +void __patch__HelloPtr(void*, ::Ice::ObjectPtr&); + +} + +namespace IceProxy +{ + +namespace Demo +{ + +class Hello : virtual public ::IceProxy::Ice::Object +{ +public: + + void sayHello() + { + sayHello(0); + } + void sayHello(const ::Ice::Context& __ctx) + { + sayHello(&__ctx); + } + +private: + + void sayHello(const ::Ice::Context*); + +public: + + void shutdown() + { + shutdown(0); + } + void shutdown(const ::Ice::Context& __ctx) + { + shutdown(&__ctx); + } + +private: + + void shutdown(const ::Ice::Context*); + +public: + + ::IceInternal::ProxyHandle<Hello> ice_context(const ::Ice::Context& __context) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_context(__context).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_context(__context).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_adapterId(const std::string& __id) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_adapterId(__id).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_adapterId(__id).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_endpoints(const ::Ice::EndpointSeq& __endpoints) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_endpoints(__endpoints).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_endpoints(__endpoints).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_locatorCacheTimeout(int __timeout) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_locatorCacheTimeout(__timeout).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_locatorCacheTimeout(__timeout).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_connectionCached(bool __cached) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_connectionCached(__cached).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_connectionCached(__cached).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_endpointSelection(::Ice::EndpointSelectionType __est) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_endpointSelection(__est).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_endpointSelection(__est).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_secure(bool __secure) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_secure(__secure).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_secure(__secure).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_preferSecure(bool __preferSecure) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_preferSecure(__preferSecure).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_preferSecure(__preferSecure).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_router(const ::Ice::RouterPrx& __router) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_router(__router).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_router(__router).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_locator(const ::Ice::LocatorPrx& __locator) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_locator(__locator).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_locator(__locator).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_collocationOptimized(bool __co) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_collocationOptimized(__co).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_collocationOptimized(__co).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_twoway() const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_twoway().get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_twoway().get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_oneway() const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_oneway().get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_oneway().get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_batchOneway() const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_batchOneway().get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_batchOneway().get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_datagram() const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_datagram().get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_datagram().get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_batchDatagram() const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_batchDatagram().get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_batchDatagram().get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_compress(bool __compress) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_compress(__compress).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_compress(__compress).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_timeout(int __timeout) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_timeout(__timeout).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_timeout(__timeout).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_connectionId(const std::string& __id) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_connectionId(__id).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_connectionId(__id).get()); + #endif + } + + ::IceInternal::ProxyHandle<Hello> ice_threadPerConnection(bool __tpc) const + { + #if defined(_MSC_VER) && (_MSC_VER < 1300) // VC++ 6 compiler bug + typedef ::IceProxy::Ice::Object _Base; + return dynamic_cast<Hello*>(_Base::ice_threadPerConnection(__tpc).get()); + #else + return dynamic_cast<Hello*>(::IceProxy::Ice::Object::ice_threadPerConnection(__tpc).get()); + #endif + } + + static const ::std::string& ice_staticId(); + +private: + + virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM(); + virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD(); + virtual ::IceProxy::Ice::Object* __newInstance() const; +}; + +} + +} + +namespace IceDelegate +{ + +namespace Demo +{ + +class Hello : virtual public ::IceDelegate::Ice::Object +{ +public: + + virtual void sayHello(const ::Ice::Context*) = 0; + + virtual void shutdown(const ::Ice::Context*) = 0; +}; + +} + +} + +namespace IceDelegateM +{ + +namespace Demo +{ + +class Hello : virtual public ::IceDelegate::Demo::Hello, + virtual public ::IceDelegateM::Ice::Object +{ +public: + + virtual void sayHello(const ::Ice::Context*); + + virtual void shutdown(const ::Ice::Context*); +}; + +} + +} + +namespace IceDelegateD +{ + +namespace Demo +{ + +class Hello : virtual public ::IceDelegate::Demo::Hello, + virtual public ::IceDelegateD::Ice::Object +{ +public: + + virtual void sayHello(const ::Ice::Context*); + + virtual void shutdown(const ::Ice::Context*); +}; + +} + +} + +namespace Demo +{ + +class Hello : virtual public ::Ice::Object +{ +public: + + typedef HelloPrx ProxyType; + typedef HelloPtr PointerType; + + virtual ::Ice::ObjectPtr ice_clone() const; + + virtual bool ice_isA(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const; + virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Current& = ::Ice::Current()) const; + virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const; + static const ::std::string& ice_staticId(); + + virtual void sayHello(const ::Ice::Current& = ::Ice::Current()) const = 0; + ::Ice::DispatchStatus ___sayHello(::IceInternal::Incoming&, const ::Ice::Current&) const; + + virtual void shutdown(const ::Ice::Current& = ::Ice::Current()) = 0; + ::Ice::DispatchStatus ___shutdown(::IceInternal::Incoming&, const ::Ice::Current&); + + virtual ::Ice::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&); + + virtual void __write(::IceInternal::BasicStream*) const; + virtual void __read(::IceInternal::BasicStream*, bool); + virtual void __write(const ::Ice::OutputStreamPtr&) const; + virtual void __read(const ::Ice::InputStreamPtr&, bool); +}; + +} + +#endif diff --git a/cpp/demo/Ice/multicast/Hello.ice b/cpp/demo/Ice/multicast/Hello.ice new file mode 100644 index 00000000000..86714e069ba --- /dev/null +++ b/cpp/demo/Ice/multicast/Hello.ice @@ -0,0 +1,24 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_ICE +#define HELLO_ICE + +module Demo +{ + +interface Hello +{ + ["cpp:const"] idempotent void sayHello(); + void shutdown(); +}; + +}; + +#endif diff --git a/cpp/demo/Ice/multicast/HelloI.cpp b/cpp/demo/Ice/multicast/HelloI.cpp new file mode 100644 index 00000000000..d6df14197a1 --- /dev/null +++ b/cpp/demo/Ice/multicast/HelloI.cpp @@ -0,0 +1,27 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceUtil/IceUtil.h> +#include <Ice/Ice.h> +#include <HelloI.h> + +using namespace std; + +void +HelloI::sayHello(const Ice::Current&) const +{ + cout << "Hello World!" << endl; +} + +void +HelloI::shutdown(const Ice::Current& c) +{ + cout << "Shutting down..." << endl; + c.adapter->getCommunicator()->shutdown(); +} diff --git a/cpp/demo/Ice/multicast/HelloI.h b/cpp/demo/Ice/multicast/HelloI.h new file mode 100644 index 00000000000..9ed84cdcfa2 --- /dev/null +++ b/cpp/demo/Ice/multicast/HelloI.h @@ -0,0 +1,23 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_I_H +#define HELLO_I_H + +#include <Hello.h> + +class HelloI : public Demo::Hello +{ +public: + + virtual void sayHello(const Ice::Current&) const; + virtual void shutdown(const Ice::Current&); +}; + +#endif diff --git a/cpp/demo/Ice/multicast/Makefile b/cpp/demo/Ice/multicast/Makefile new file mode 100644 index 00000000000..4a69f0abd12 --- /dev/null +++ b/cpp/demo/Ice/multicast/Makefile @@ -0,0 +1,42 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +CLIENT = client +SERVER = server + +TARGETS = $(CLIENT) $(SERVER) + +OBJS = Hello.o + +COBJS = Client.o + +SOBJS = HelloI.o \ + Server.o + +SRCS = $(OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) + +SLICE_SRCS = Hello.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. $(CPPFLAGS) + +$(CLIENT): $(OBJS) $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) + +$(SERVER): $(OBJS) $(SOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SOBJS) $(LIBS) + +include .depend diff --git a/cpp/demo/Ice/multicast/Makefile.mak b/cpp/demo/Ice/multicast/Makefile.mak new file mode 100644 index 00000000000..51e29b67d27 --- /dev/null +++ b/cpp/demo/Ice/multicast/Makefile.mak @@ -0,0 +1,50 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ..\..\.. + +CLIENT = client.exe +SERVER = server.exe + +TARGETS = $(CLIENT) $(SERVER) + +OBJS = Hello.obj + +COBJS = Client.obj + +SOBJS = HelloI.obj \ + Server.obj + +SRCS = $(OBJS:.obj=.cpp) \ + $(COBJS:.obj=.cpp) \ + $(SOBJS:.obj=.cpp) + +!include $(top_srcdir)/config/Make.rules.mak + +CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN + +!if "$(CPP_COMPILER)" != "BCC2006" && "$(OPTIMIZE)" != "yes" +CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb) +SPDBFLAGS = /pdb:$(SERVER:.exe=.pdb) +!endif + +$(CLIENT): $(OBJS) $(COBJS) + $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(OBJS) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +$(SERVER): $(OBJS) $(SOBJS) + $(LINK) $(LD_EXEFLAGS) $(SPDBFLAGS) $(SETARGV) $(OBJS) $(SOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +clean:: + del /q Hello.cpp Hello.h + +!include .depend diff --git a/cpp/demo/Ice/multicast/README b/cpp/demo/Ice/multicast/README new file mode 100644 index 00000000000..5d9452b085b --- /dev/null +++ b/cpp/demo/Ice/multicast/README @@ -0,0 +1,12 @@ +This demo illustrates how to use UDP multicast to send messages. + +To run the demo, first start multiple instances of the server: + +$ server + +In a separate window, start a client: + +$ client + +When you send a message you will notice that it is received by all +running servers. diff --git a/cpp/demo/Ice/multicast/Server.cpp b/cpp/demo/Ice/multicast/Server.cpp new file mode 100644 index 00000000000..ade188d45db --- /dev/null +++ b/cpp/demo/Ice/multicast/Server.cpp @@ -0,0 +1,43 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <HelloI.h> + +using namespace std; + +class MulticastServer : public Ice::Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + MulticastServer app; + return app.main(argc, argv, "config.server"); +} + +int +MulticastServer::run(int argc, char* argv[]) +{ + if(argc > 1) + { + cerr << appName() << ": too many arguments" << endl; + return EXIT_FAILURE; + } + + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello"); + adapter->add(new HelloI, communicator()->stringToIdentity("hello")); + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; +} diff --git a/cpp/demo/Ice/multicast/config.client b/cpp/demo/Ice/multicast/config.client new file mode 100644 index 00000000000..8dd66d37f92 --- /dev/null +++ b/cpp/demo/Ice/multicast/config.client @@ -0,0 +1,28 @@ +# +# The client reads this property to create the reference to the +# "hello" object in the server. +# +Hello.Proxy=hello:udp -h 224.0.0.5 -p 10000 + +# +# Warn about connection exceptions +# +#Ice.Warn.Connections=1 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +#Ice.Trace.Network=1 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +#Ice.Trace.Protocol=1 diff --git a/cpp/demo/Ice/multicast/config.server b/cpp/demo/Ice/multicast/config.server new file mode 100644 index 00000000000..1bb94c4644a --- /dev/null +++ b/cpp/demo/Ice/multicast/config.server @@ -0,0 +1,29 @@ +# +# The server creates one single object adapter with the name +# "Hello". The following line sets the endpoints for this +# adapter. +# +Hello.Endpoints=udp -h 224.0.0.5 -p 10000 + +# +# Warn about connection exceptions +# +#Ice.Warn.Connections=1 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +#Ice.Trace.Network=1 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +#Ice.Trace.Protocol=1 diff --git a/cpp/demo/Ice/multicast/expect.py b/cpp/demo/Ice/multicast/expect.py new file mode 100755 index 00000000000..d6d04a1c0e6 --- /dev/null +++ b/cpp/demo/Ice/multicast/expect.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.multicast +demoscript.Util.defaultLanguage = "C++" + +server1 = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server1.expect('.* ready') +server2 = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server2.expect('.* ready') +server3 = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server3.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +demoscript.Ice.multicast.run(client, server1, server2, server3) diff --git a/cpp/demo/Ice/multicast/multicastC.dsp b/cpp/demo/Ice/multicast/multicastC.dsp new file mode 100644 index 00000000000..06497120d81 --- /dev/null +++ b/cpp/demo/Ice/multicast/multicastC.dsp @@ -0,0 +1,157 @@ +# Microsoft Developer Studio Project File - Name="multicastC" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=multicastC - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "multicastC.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "multicastC.mak" CFG="multicastC - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "multicastC - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "multicastC - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "multicastC - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "NDEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Ice.lib IceUtil.lib setargv.obj /nologo /subsystem:console /pdb:none /machine:I386 /out:"client.exe" /libpath:"../../../lib" /FIXED:no
+# SUBTRACT LINK32 /debug /nodefaultlib
+
+!ELSEIF "$(CFG)" == "multicastC - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "_DEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /GZ /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Iced.lib IceUtild.lib setargv.obj /nologo /subsystem:console /debug /machine:I386 /out:"client.exe" /pdbtype:sept /libpath:"../../../lib" /FIXED:no
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "multicastC - Win32 Release"
+# Name "multicastC - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Client.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Hello.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Hello.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\Hello.ice
+
+!IF "$(CFG)" == "multicastC - Win32 Release"
+
+USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\slice.lib"
+# Begin Custom Build
+InputPath=.\Hello.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe Hello.ice
+
+"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "multicastC - Win32 Debug"
+
+USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\sliced.lib"
+# Begin Custom Build
+InputPath=.\Hello.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe Hello.ice
+
+"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\README
+# End Source File
+# End Target
+# End Project
diff --git a/cpp/demo/Ice/multicast/multicastS.dsp b/cpp/demo/Ice/multicast/multicastS.dsp new file mode 100644 index 00000000000..620a0a9f72a --- /dev/null +++ b/cpp/demo/Ice/multicast/multicastS.dsp @@ -0,0 +1,165 @@ +# Microsoft Developer Studio Project File - Name="multicastS" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=multicastS - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "multicastS.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "multicastS.mak" CFG="multicastS - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "multicastS - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "multicastS - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "multicastS - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "NDEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Ice.lib IceUtil.lib setargv.obj /nologo /subsystem:console /pdb:none /machine:I386 /out:"server.exe" /libpath:"../../../lib" /FIXED:no
+# SUBTRACT LINK32 /debug /nodefaultlib
+
+!ELSEIF "$(CFG)" == "multicastS - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../../include/stlport" /D "_CONSOLE" /D "_DEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /GZ /c
+# SUBTRACT CPP /Fr /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Iced.lib IceUtild.lib setargv.obj /nologo /subsystem:console /debug /machine:I386 /out:"server.exe" /pdbtype:sept /libpath:"../../../lib" /FIXED:no
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "multicastS - Win32 Release"
+# Name "multicastS - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Hello.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\HelloI.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Hello.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\HelloI.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\Hello.ice
+
+!IF "$(CFG)" == "multicastS - Win32 Release"
+
+USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\slice.lib"
+# Begin Custom Build
+InputPath=.\Hello.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe Hello.ice
+
+"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "multicastS - Win32 Debug"
+
+USERDEP__HELLO="..\..\..\bin\slice2cpp.exe" "..\..\..\lib\sliced.lib"
+# Begin Custom Build
+InputPath=.\Hello.ice
+
+BuildCmds= \
+ ..\..\..\bin\slice2cpp.exe Hello.ice
+
+"Hello.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Hello.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\README
+# End Source File
+# End Target
+# End Project
diff --git a/cpp/demo/IceGrid/icebox/.gitignore b/cpp/demo/IceGrid/icebox/.gitignore index aeed8d875bf..20a7b29a4a9 100644 --- a/cpp/demo/IceGrid/icebox/.gitignore +++ b/cpp/demo/IceGrid/icebox/.gitignore @@ -2,8 +2,6 @@ // IMPORTANT: Do not edit this file -- any edits made here will be lost! client -server +libHelloService.so Hello.cpp Hello.h -db/node/* -db/registry/* diff --git a/cpp/test/Ice/background/.gitignore b/cpp/test/Ice/background/.gitignore index 67872faa673..70003eefc96 100644 --- a/cpp/test/Ice/background/.gitignore +++ b/cpp/test/Ice/background/.gitignore @@ -3,5 +3,8 @@ // IMPORTANT: Do not edit this file -- any edits made here will be lost! client server +libTestTransport.so.3.3.0 +libTestTransport.so.33 +libTestTransport.so Test.cpp Test.h diff --git a/cs/allDemos.py b/cs/allDemos.py index 19a6520782d..a58ab77bfc6 100755 --- a/cs/allDemos.py +++ b/cs/allDemos.py @@ -65,6 +65,7 @@ demos = [ "Ice/invoke", "Ice/latency", "Ice/minimal", + #"Ice/multicast", "Ice/nested", "Ice/session", "Ice/throughput", diff --git a/cs/demo/Ice/Makefile b/cs/demo/Ice/Makefile index 1224c4b660e..cd019216bc3 100644 --- a/cs/demo/Ice/Makefile +++ b/cs/demo/Ice/Makefile @@ -21,7 +21,8 @@ SUBDIRS = bidir \ session \ throughput \ value \ - async + async \ + multicast $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cs/demo/Ice/Makefile.mak b/cs/demo/Ice/Makefile.mak index c09cd9dd8a9..4e96607eb45 100755 --- a/cs/demo/Ice/Makefile.mak +++ b/cs/demo/Ice/Makefile.mak @@ -21,7 +21,8 @@ SUBDIRS = bidir \ session \ throughput \ value \ - async + async \ + multicast $(EVERYTHING):: @for %i in ( $(SUBDIRS) ) do \ diff --git a/cs/demo/Ice/README b/cs/demo/Ice/README index 6dbee2c5a4c..ed7506e7146 100644 --- a/cs/demo/Ice/README +++ b/cs/demo/Ice/README @@ -38,6 +38,10 @@ Demos in this directory: This demo illustrates a minimal Ice application. +- multicast + + This demo illustrates the use of UDP multicast. + - nested A demo to illustrate how nested callbacks work, and how the size of diff --git a/cs/demo/Ice/multicast/.depend b/cs/demo/Ice/multicast/.depend new file mode 100644 index 00000000000..d36db71ec3d --- /dev/null +++ b/cs/demo/Ice/multicast/.depend @@ -0,0 +1 @@ +Hello.cs: ./Hello.ice diff --git a/cs/demo/Ice/multicast/Client.cs b/cs/demo/Ice/multicast/Client.cs new file mode 100755 index 00000000000..d4b1e6e5050 --- /dev/null +++ b/cs/demo/Ice/multicast/Client.cs @@ -0,0 +1,90 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +using System; +using Demo; + +public class Client : Ice.Application +{ + private static void menu() + { + Console.Write( + "usage:\n" + + "t: send multicast message\n" + + "s: shutdown server\n" + + "x: exit\n" + + "?: help\n"); + } + + public override int run(string[] args) + { + if(args.Length > 0) + { + Console.Error.WriteLine(appName() + ": too many arguments"); + return 1; + } + + HelloPrx proxy = HelloPrxHelper.uncheckedCast(communicator().propertyToProxy("Hello.Proxy").ice_datagram()); + + menu(); + + string line = null; + do + { + try + { + Console.Out.Write("==> "); + Console.Out.Flush(); + line = Console.In.ReadLine(); + if(line == null) + { + break; + } + if(line.Equals("t")) + { + proxy.sayHello(); + } + else if(line.Equals("s")) + { + proxy.shutdown(); + } + else if(line.Equals("x")) + { + // Nothing to do + } + else if(line.Equals("?")) + { + menu(); + } + else + { + Console.WriteLine("unknown command `" + line + "'"); + menu(); + } + } + catch(System.Exception ex) + { + Console.Error.WriteLine(ex); + } + } + while (!line.Equals("x")); + + return 0; + } + + public static void Main(string[] args) + { + Client app = new Client(); + int status = app.main(args, "config.client"); + if(status != 0) + { + System.Environment.Exit(status); + } + } +} diff --git a/cs/demo/Ice/multicast/Hello.ice b/cs/demo/Ice/multicast/Hello.ice new file mode 100644 index 00000000000..86714e069ba --- /dev/null +++ b/cs/demo/Ice/multicast/Hello.ice @@ -0,0 +1,24 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_ICE +#define HELLO_ICE + +module Demo +{ + +interface Hello +{ + ["cpp:const"] idempotent void sayHello(); + void shutdown(); +}; + +}; + +#endif diff --git a/cs/demo/Ice/multicast/HelloI.cs b/cs/demo/Ice/multicast/HelloI.cs new file mode 100755 index 00000000000..0e3b5f92dd8 --- /dev/null +++ b/cs/demo/Ice/multicast/HelloI.cs @@ -0,0 +1,24 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +using Demo; + +public class HelloI : HelloDisp_ +{ + public override void sayHello(Ice.Current current) + { + System.Console.Out.WriteLine("Hello World!"); + } + + public override void shutdown(Ice.Current current) + { + System.Console.Out.WriteLine("Shutting down..."); + current.adapter.getCommunicator().shutdown(); + } +} diff --git a/cs/demo/Ice/multicast/Makefile b/cs/demo/Ice/multicast/Makefile new file mode 100644 index 00000000000..5333dbbca03 --- /dev/null +++ b/cs/demo/Ice/multicast/Makefile @@ -0,0 +1,35 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +TARGETS = client.exe server.exe + +C_SRCS = Client.cs +S_SRCS = HelloI.cs Server.cs + +SLICE_SRCS = $(SDIR)/Hello.ice + +SDIR = . + +GDIR = generated + +include $(top_srcdir)/config/Make.rules.cs + +MCSFLAGS := $(MCSFLAGS) -target:exe + +SLICE2CSFLAGS := $(SLICE2CSFLAGS) --ice -I. -I$(slicedir) + +client.exe: $(C_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +server.exe: $(S_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +include .depend diff --git a/cs/demo/Ice/multicast/Makefile.mak b/cs/demo/Ice/multicast/Makefile.mak new file mode 100644 index 00000000000..b44aeebd6e0 --- /dev/null +++ b/cs/demo/Ice/multicast/Makefile.mak @@ -0,0 +1,35 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ..\..\.. + +TARGETS = client.exe server.exe + +C_SRCS = Client.cs +S_SRCS = HelloI.cs Server.cs + +GEN_SRCS = $(GDIR)\Hello.cs + +SDIR = . + +GDIR = generated + +!include $(top_srcdir)\config\Make.rules.mak.cs + +MCSFLAGS = $(MCSFLAGS) -target:exe + +SLICE2CSFLAGS = $(SLICE2CSFLAGS) --ice -I. -I$(slicedir) + +client.exe: $(C_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(C_SRCS) $(GEN_SRCS) + +server.exe: $(S_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(S_SRCS) $(GEN_SRCS) + +!include .depend diff --git a/cs/demo/Ice/multicast/README b/cs/demo/Ice/multicast/README new file mode 100644 index 00000000000..5d9452b085b --- /dev/null +++ b/cs/demo/Ice/multicast/README @@ -0,0 +1,12 @@ +This demo illustrates how to use UDP multicast to send messages. + +To run the demo, first start multiple instances of the server: + +$ server + +In a separate window, start a client: + +$ client + +When you send a message you will notice that it is received by all +running servers. diff --git a/cs/demo/Ice/multicast/Server.cs b/cs/demo/Ice/multicast/Server.cs new file mode 100755 index 00000000000..a76ccdf91a9 --- /dev/null +++ b/cs/demo/Ice/multicast/Server.cs @@ -0,0 +1,36 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +public class Server : Ice.Application +{ + public override int run(string[] args) + { + if(args.Length > 0) + { + System.Console.Error.WriteLine(appName() + ": too many arguments"); + return 1; + } + + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); + adapter.add(new HelloI(), communicator().stringToIdentity("hello")); + adapter.activate(); + communicator().waitForShutdown(); + return 0; + } + + public static void Main(string[] args) + { + Server app = new Server(); + int status = app.main(args, "config.server"); + if(status != 0) + { + System.Environment.Exit(status); + } + } +} diff --git a/cs/demo/Ice/multicast/client.exe.config b/cs/demo/Ice/multicast/client.exe.config new file mode 100755 index 00000000000..1eeb15fea8f --- /dev/null +++ b/cs/demo/Ice/multicast/client.exe.config @@ -0,0 +1,35 @@ +<?xml version="1.0"?> + <configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="glacier2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/glacier2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icecs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icecs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icepatch2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icepatch2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icestormcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icestormcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="iceboxcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/iceboxcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icegridcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icegridcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icesslcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icesslcs.dll"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/cs/demo/Ice/multicast/config.client b/cs/demo/Ice/multicast/config.client new file mode 100644 index 00000000000..8dd66d37f92 --- /dev/null +++ b/cs/demo/Ice/multicast/config.client @@ -0,0 +1,28 @@ +# +# The client reads this property to create the reference to the +# "hello" object in the server. +# +Hello.Proxy=hello:udp -h 224.0.0.5 -p 10000 + +# +# Warn about connection exceptions +# +#Ice.Warn.Connections=1 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +#Ice.Trace.Network=1 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +#Ice.Trace.Protocol=1 diff --git a/cs/demo/Ice/multicast/config.server b/cs/demo/Ice/multicast/config.server new file mode 100644 index 00000000000..1bb94c4644a --- /dev/null +++ b/cs/demo/Ice/multicast/config.server @@ -0,0 +1,29 @@ +# +# The server creates one single object adapter with the name +# "Hello". The following line sets the endpoints for this +# adapter. +# +Hello.Endpoints=udp -h 224.0.0.5 -p 10000 + +# +# Warn about connection exceptions +# +#Ice.Warn.Connections=1 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +#Ice.Trace.Network=1 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +#Ice.Trace.Protocol=1 diff --git a/cs/demo/Ice/multicast/expect.py b/cs/demo/Ice/multicast/expect.py new file mode 100755 index 00000000000..6c26c4afdac --- /dev/null +++ b/cs/demo/Ice/multicast/expect.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.multicast +demoscript.Util.defaultLanguage = "C#" + +server1 = demoscript.Util.spawn('server.exe --Ice.PrintAdapterReady') +server1.expect('.* ready') +server2 = demoscript.Util.spawn('server.exe --Ice.PrintAdapterReady') +server2.expect('.* ready') +server3 = demoscript.Util.spawn('server.exe --Ice.PrintAdapterReady') +server3.expect('.* ready') +client = demoscript.Util.spawn('client.exe') +client.expect('.*==>') + +demoscript.Ice.multicast.run(client, server1, server2, server3) diff --git a/cs/demo/Ice/multicast/multicastC.csproj b/cs/demo/Ice/multicast/multicastC.csproj new file mode 100755 index 00000000000..5f132ed0c1c --- /dev/null +++ b/cs/demo/Ice/multicast/multicastC.csproj @@ -0,0 +1,117 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectType>Local</ProjectType>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{228B2AFC-57DC-4E1F-8335-D0CD657A987B}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ <AssemblyKeyContainerName>
+ </AssemblyKeyContainerName>
+ <AssemblyName>client</AssemblyName>
+ <AssemblyOriginatorKeyFile>
+ </AssemblyOriginatorKeyFile>
+ <DefaultClientScript>JScript</DefaultClientScript>
+ <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+ <DefaultTargetSchema>IE50</DefaultTargetSchema>
+ <DelaySign>false</DelaySign>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>
+ </RootNamespace>
+ <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+ <StartupObject>
+ </StartupObject>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <OutputPath>.\</OutputPath>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>true</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <NoStdLib>false</NoStdLib>
+ <NoWarn>
+ </NoWarn>
+ <Optimize>false</Optimize>
+ <RegisterForComInterop>false</RegisterForComInterop>
+ <RemoveIntegerChecks>false</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <DebugType>full</DebugType>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <OutputPath>.\</OutputPath>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>TRACE</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>false</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <NoStdLib>false</NoStdLib>
+ <NoWarn>
+ </NoWarn>
+ <Optimize>true</Optimize>
+ <RegisterForComInterop>false</RegisterForComInterop>
+ <RemoveIntegerChecks>false</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <DebugType>none</DebugType>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="icecs">
+ <Name>icecs</Name>
+ <HintPath>..\..\..\bin\icecs.dll</HintPath>
+ </Reference>
+ <Reference Include="System">
+ <Name>System</Name>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Client.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="generated\Hello.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="README" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+ <Target Name="CompileSlice"
+ Inputs="Hello.ice"
+ Outputs="generated\Hello.cs">
+ <Exec Command="$(ICE_HOME)\bin\slice2cs.exe --output-dir generated Hello.ice"/>
+ </Target>
+ <Target Name="AfterClean">
+ <Delete Files="generated\Hello.cs"/>
+ </Target>
+ <PropertyGroup>
+ <CompileDependsOn>
+ CompileSlice;$(CompileDependsOn)
+ </CompileDependsOn>
+ </PropertyGroup>
+</Project>
diff --git a/cs/demo/Ice/multicast/multicastS.csproj b/cs/demo/Ice/multicast/multicastS.csproj new file mode 100755 index 00000000000..5d56c2a0088 --- /dev/null +++ b/cs/demo/Ice/multicast/multicastS.csproj @@ -0,0 +1,118 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectType>Local</ProjectType>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{0B41ADFF-7802-4A36-8374-C32DE33B0290}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ <AssemblyKeyContainerName>
+ </AssemblyKeyContainerName>
+ <AssemblyName>server</AssemblyName>
+ <AssemblyOriginatorKeyFile>
+ </AssemblyOriginatorKeyFile>
+ <DefaultClientScript>JScript</DefaultClientScript>
+ <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+ <DefaultTargetSchema>IE50</DefaultTargetSchema>
+ <DelaySign>false</DelaySign>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>
+ </RootNamespace>
+ <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+ <StartupObject>
+ </StartupObject>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <OutputPath>.\</OutputPath>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>true</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <NoStdLib>false</NoStdLib>
+ <NoWarn>
+ </NoWarn>
+ <Optimize>false</Optimize>
+ <RegisterForComInterop>false</RegisterForComInterop>
+ <RemoveIntegerChecks>false</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <DebugType>full</DebugType>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <OutputPath>.\</OutputPath>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <BaseAddress>285212672</BaseAddress>
+ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+ <ConfigurationOverrideFile>
+ </ConfigurationOverrideFile>
+ <DefineConstants>TRACE</DefineConstants>
+ <DocumentationFile>
+ </DocumentationFile>
+ <DebugSymbols>false</DebugSymbols>
+ <FileAlignment>4096</FileAlignment>
+ <NoStdLib>false</NoStdLib>
+ <NoWarn>
+ </NoWarn>
+ <Optimize>true</Optimize>
+ <RegisterForComInterop>false</RegisterForComInterop>
+ <RemoveIntegerChecks>false</RemoveIntegerChecks>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <WarningLevel>4</WarningLevel>
+ <DebugType>none</DebugType>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="icecs">
+ <Name>icecs</Name>
+ <HintPath>..\..\..\bin\icecs.dll</HintPath>
+ </Reference>
+ <Reference Include="System">
+ <Name>System</Name>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="generated\Hello.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="HelloI.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Server.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="README" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+ <Target Name="CompileSlice" Inputs="Hello.ice" Outputs="generated\Hello.cs">
+ <Exec Command="$(ICE_HOME)\bin\slice2cs.exe --output-dir generated Hello.ice" />
+ </Target>
+ <Target Name="AfterClean">
+ <Delete Files="generated\Hello.cs"/>
+ </Target>
+ <PropertyGroup>
+ <CompileDependsOn>
+ CompileSlice;$(CompileDependsOn)
+ </CompileDependsOn>
+ </PropertyGroup>
+</Project>
diff --git a/cs/demo/Ice/multicast/server.exe.config b/cs/demo/Ice/multicast/server.exe.config new file mode 100755 index 00000000000..1eeb15fea8f --- /dev/null +++ b/cs/demo/Ice/multicast/server.exe.config @@ -0,0 +1,35 @@ +<?xml version="1.0"?> + <configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="glacier2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/glacier2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icecs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icecs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icepatch2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icepatch2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icestormcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icestormcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="iceboxcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/iceboxcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icegridcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icegridcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icesslcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.3.0.0" href="../../../bin/icesslcs.dll"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/demoscript/Ice/multicast.py b/demoscript/Ice/multicast.py new file mode 100644 index 00000000000..0cf2c4a45e9 --- /dev/null +++ b/demoscript/Ice/multicast.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys +import demoscript.pexpect as pexpect + +def run(client, server1, server2, server3): + print "testing multicast...", + sys.stdout.flush() + + client.sendline('t') + server1.expect('Hello World!') + server2.expect('Hello World!') + server3.expect('Hello World!') + + client.sendline('t') + server1.expect('Hello World!') + server2.expect('Hello World!') + server3.expect('Hello World!') + + client.sendline('s') + server1.waitTestSuccess() + server2.waitTestSuccess() + server3.waitTestSuccess() + + client.sendline('x') + client.waitTestSuccess() + + print "ok" diff --git a/java/allDemos.py b/java/allDemos.py index ded2a85ca94..675b5cfb356 100755 --- a/java/allDemos.py +++ b/java/allDemos.py @@ -65,6 +65,7 @@ demos = [ "Ice/invoke", "Ice/latency", "Ice/minimal", + "Ice/multicast", "Ice/nested", "Ice/session", "Ice/throughput", diff --git a/java/demo/Ice/README b/java/demo/Ice/README index 6dbee2c5a4c..ed7506e7146 100644 --- a/java/demo/Ice/README +++ b/java/demo/Ice/README @@ -38,6 +38,10 @@ Demos in this directory: This demo illustrates a minimal Ice application. +- multicast + + This demo illustrates the use of UDP multicast. + - nested A demo to illustrate how nested callbacks work, and how the size of diff --git a/java/demo/Ice/build.xml b/java/demo/Ice/build.xml index b238c7e452d..809e521aa5f 100644 --- a/java/demo/Ice/build.xml +++ b/java/demo/Ice/build.xml @@ -23,6 +23,7 @@ <ant dir="value"/> <ant dir="session"/> <ant dir="async"/> + <ant dir="multicast"/> </target> <target name="clean"> @@ -37,6 +38,7 @@ <ant dir="value" target="clean"/> <ant dir="session" target="clean"/> <ant dir="async" target="clean"/> + <ant dir="multicast" target="clean"/> </target> </project> diff --git a/java/demo/Ice/multicast/Client.java b/java/demo/Ice/multicast/Client.java new file mode 100644 index 00000000000..b5ea6c11d42 --- /dev/null +++ b/java/demo/Ice/multicast/Client.java @@ -0,0 +1,119 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import Demo.*; + +public class Client extends Ice.Application +{ + class ShutdownHook extends Thread + { + public void + run() + { + try + { + communicator().destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } + } + + private static void + menu() + { + System.out.println( + "usage:\n" + + "t: send multicast message\n" + + "s: shutdown server\n" + + "x: exit\n" + + "?: help\n"); + } + + public int + run(String[] args) + { + if(args.length > 0) + { + System.err.println(appName() + ": too many arguments"); + return 1; + } + + // + // Since this is an interactive demo we want to clear the + // Application installed interrupt callback and install our + // own shutdown hook. + // + setInterruptHook(new ShutdownHook()); + + HelloPrx proxy = HelloPrxHelper.uncheckedCast(communicator().propertyToProxy("Hello.Proxy").ice_datagram()); + + menu(); + + java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); + + String line = null; + do + { + try + { + System.out.print("==> "); + System.out.flush(); + line = in.readLine(); + if(line == null) + { + break; + } + if(line.equals("t")) + { + proxy.sayHello(); + } + else if(line.equals("s")) + { + proxy.shutdown(); + } + else if(line.equals("x")) + { + // Nothing to do + } + else if(line.equals("?")) + { + menu(); + } + else + { + System.out.println("unknown command `" + line + "'"); + menu(); + } + } + catch(java.io.IOException ex) + { + ex.printStackTrace(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } + while(!line.equals("x")); + + return 0; + } + + public static void + main(String[] args) + { + Client app = new Client(); + int status = app.main("Client", args, "config.client"); + System.exit(status); + } +} + diff --git a/java/demo/Ice/multicast/Hello.ice b/java/demo/Ice/multicast/Hello.ice new file mode 100644 index 00000000000..86714e069ba --- /dev/null +++ b/java/demo/Ice/multicast/Hello.ice @@ -0,0 +1,24 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_ICE +#define HELLO_ICE + +module Demo +{ + +interface Hello +{ + ["cpp:const"] idempotent void sayHello(); + void shutdown(); +}; + +}; + +#endif diff --git a/java/demo/Ice/multicast/HelloI.java b/java/demo/Ice/multicast/HelloI.java new file mode 100644 index 00000000000..7a779f2d9da --- /dev/null +++ b/java/demo/Ice/multicast/HelloI.java @@ -0,0 +1,26 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import Demo.*; + +public class HelloI extends _HelloDisp +{ + public void + sayHello(Ice.Current current) + { + System.out.println("Hello World!"); + } + + public void + shutdown(Ice.Current current) + { + System.out.println("Shutting down..."); + current.adapter.getCommunicator().shutdown(); + } +} diff --git a/java/demo/Ice/multicast/README b/java/demo/Ice/multicast/README new file mode 100644 index 00000000000..5053bcabad9 --- /dev/null +++ b/java/demo/Ice/multicast/README @@ -0,0 +1,12 @@ +This demo illustrates how to use UDP multicast to send messages. + +To run the demo, first start multiple instances of the server: + +$ java Server + +In a separate window, start a client: + +$ java Client + +When you send a message you will notice that it is received by all +running servers. diff --git a/java/demo/Ice/multicast/Server.java b/java/demo/Ice/multicast/Server.java new file mode 100644 index 00000000000..06f6576471c --- /dev/null +++ b/java/demo/Ice/multicast/Server.java @@ -0,0 +1,37 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import Demo.*; + +public class Server extends Ice.Application +{ + public int + run(String[] args) + { + if(args.length > 0) + { + System.err.println(appName() + ": too many arguments"); + return 1; + } + + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); + adapter.add(new HelloI(), communicator().stringToIdentity("hello")); + adapter.activate(); + communicator().waitForShutdown(); + return 0; + } + + public static void + main(String[] args) + { + Server app = new Server(); + int status = app.main("Server", args, "config.server"); + System.exit(status); + } +} diff --git a/java/demo/Ice/multicast/build.xml b/java/demo/Ice/multicast/build.xml new file mode 100644 index 00000000000..ccec3def1b6 --- /dev/null +++ b/java/demo/Ice/multicast/build.xml @@ -0,0 +1,50 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. + + This copy of Ice is licensed to you under the terms described in the + ICE_LICENSE file included in this distribution. + + ********************************************************************** +--> + +<project name="demo_Ice_multicast" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../.."/> + + <!-- import common definitions --> + <import file="${top.dir}/config/common.xml"/> + + <target name="generate" depends="init"> + <!-- Create the output directory for generated code --> + <mkdir dir="${generated.dir}"/> + <slice2java outputdir="${generated.dir}"> + <meta value="${java2metadata}"/> + <fileset dir="." includes="Hello.ice"/> + </slice2java> + </target> + + <target name="compile" depends="generate"> + <mkdir dir="${class.dir}"/> + <javac srcdir="${generated.dir}" destdir="${class.dir}" + source="${jdk.version}" debug="${debug}"> + <classpath refid="ice.classpath"/> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + <javac srcdir="." destdir="${class.dir}" source="${jdk.version}" + excludes="generated/**" debug="${debug}"> + <classpath refid="ice.classpath"/> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + </target> + + <target name="all" depends="compile"/> + + <target name="clean"> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> diff --git a/java/demo/Ice/multicast/config.client b/java/demo/Ice/multicast/config.client new file mode 100644 index 00000000000..8dd66d37f92 --- /dev/null +++ b/java/demo/Ice/multicast/config.client @@ -0,0 +1,28 @@ +# +# The client reads this property to create the reference to the +# "hello" object in the server. +# +Hello.Proxy=hello:udp -h 224.0.0.5 -p 10000 + +# +# Warn about connection exceptions +# +#Ice.Warn.Connections=1 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +#Ice.Trace.Network=1 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +#Ice.Trace.Protocol=1 diff --git a/java/demo/Ice/multicast/config.server b/java/demo/Ice/multicast/config.server new file mode 100644 index 00000000000..1bb94c4644a --- /dev/null +++ b/java/demo/Ice/multicast/config.server @@ -0,0 +1,29 @@ +# +# The server creates one single object adapter with the name +# "Hello". The following line sets the endpoints for this +# adapter. +# +Hello.Endpoints=udp -h 224.0.0.5 -p 10000 + +# +# Warn about connection exceptions +# +#Ice.Warn.Connections=1 + +# +# Network Tracing +# +# 0 = no network tracing +# 1 = trace connection establishment and closure +# 2 = like 1, but more detailed +# 3 = like 2, but also trace data transfer +# +#Ice.Trace.Network=1 + +# +# Protocol Tracing +# +# 0 = no protocol tracing +# 1 = trace protocol messages +# +#Ice.Trace.Protocol=1 diff --git a/java/demo/Ice/multicast/expect.py b/java/demo/Ice/multicast/expect.py new file mode 100755 index 00000000000..d27d7d37fd3 --- /dev/null +++ b/java/demo/Ice/multicast/expect.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.multicast +demoscript.Util.defaultLanguage = "Java" + +server1 = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server1.expect('.* ready') +server2 = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server2.expect('.* ready') +server3 = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server3.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('.*==>') + +demoscript.Ice.multicast.run(client, server1, server2, server3) |