Archived

This forum has been archived. Please start a new discussion on GitHub.

Clients in server

Hi,

I have two servers. Is there an example of how to embed a client in server 1 making a call to server2? If not can you give me some idea on how to this? I get everything to compile but get lots of link errors about methods being already defined.

Thanks for your help,

John

Comments

  • mes
    mes California
    There is nothing special you need to do for an Ice application to be both client and server. The example in demo/Ice/nested may interest you; it involves two servers that make nested invocations to each other.

    If you're still having trouble, please provide more information:
    • Platform & compiler version
    • Compile/link errors
    • Anything else you think might be useful

    Take care,
    - Mark
  • Hi Mark,

    Thanks for your reply. I looked at the nested example and I'm not sure I have the same situation.

    The compiler is VC++ 6.0 on Windows XP. Below is a partial list of the link errors.

    I have two different ice files (Que.ice and PLDBServer.ice). One server
    (Que.cpp) is a queing server to feed several different (PLDBServer.cpp) servers. I create a thread using the IceUtil Thread class in the Que server and try to create a client to the PLDBServer in there. This is where I'm getting the link errors.

    I'll look at the nested example in more detail (been in meetings all day)
    and see what's going on there.

    Thanks for your help,
    John





    Deleting intermediate files and output files for project 'QServer - Win32 Release'.
    Configuration: QServer - Win32 Release
    Compiling...
    DBWatcherThread.cpp
    QServer.cpp
    Que.cpp
    QueManagerI.cpp
    PLDBServer.cpp
    Linking...
    Que.obj : error LNK2005: "public: bool __thiscall PLDBRequest::operator==(struct PLDBRequest const &)const " (??8PLDBRequest@@QBE_NABU0@@Z) already defined in DBWatcherThread.obj
    Que.obj : error LNK2005: "public: bool __thiscall PLDBRequest::operator!=(struct PLDBRequest const &)const " (??9PLDBRequest@@QBE_NABU0@@Z) already defined in DBWatcherThread.obj
    Que.obj : error LNK2005: "public: bool __thiscall PLDBRequest::operator<(struct PLDBRequest const &)const " (??MPLDBRequest@@QBE_NABU0@@Z) already defined in DBWatcherThread.obj
    Que.obj : error LNK2005: "public: void __thiscall PLDBRequest::__write(class IceInternal::BasicStream *)const " (?__write@PLDBRequest@@Z) already defined in DBWatcherThread.obj
    Que.obj : error LNK2005: "public: void __thiscall PLDBRequest::__read(class IceInternal::BasicStream *)" (?__read@PLDBRequest@@Z) already defined in DBWatcherThread.obj
    Que.obj : error LNK2005: "public: void __thiscall PLDBRequest::ice_marshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &)const " (?ice_marshal@P
    LDBRequest@@QBEXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@Z) already defined in DBWatcherThread.obj
    Que.obj : error LNK2005: "public: void __thiscall PLDBRequest::ice_unmarshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &)" (?ice_unmarshal@PLD
    BRequest@@QAEXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::incRef(class PLDBServer *)" (?incRef@IceInternal@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::decRef(class PLDBServer *)" (?decRef@IceInternal@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::incRef(class IceProxy::PLDBServer *)" (?incRef@IceInternal@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::decRef(class IceProxy::PLDBServer *)" (?decRef@IceInternal@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::checkedCast(class IceInternal::ProxyHandle<class IceProxy::Ice::Object> const &,class IceInternal::ProxyHandle<class IceProxy::PLDBServer> &)" (?checkedCast@IceInternal@@YAXABV?$ProxyHandle@
    @1@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::checkedCast(class IceInternal::ProxyHandle<class IceProxy::Ice::Object> const &,class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInt
    ernal::ProxyHandle<class IceProxy::PLDBServer> &)" (?checkedCast@IceInternal@@1@ABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@1@@Z) already define
    d in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::uncheckedCast(class IceInternal::ProxyHandle<class IceProxy::Ice::Object> const &,class IceInternal::ProxyHandle<class IceProxy::PLDBServer> &)" (?uncheckedCast@IceInternal@@YAXABV?$ProxyHan
    @1@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl IceInternal::uncheckedCast(class IceInternal::ProxyHandle<class IceProxy::Ice::Object> const &,class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceI
    nternal::ProxyHandle<class IceProxy::PLDBServer> &)" (?uncheckedCast@IceInternal@@1@ABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@1@@Z) already de
    fined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl __write(class IceInternal::BasicStream *,class IceInternal::ProxyHandle<class IceProxy::PLDBServer> const &)" (?__write@@YAXPAVBasicStream@IceInternal@@2@@Z) alrea
    dy defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl __read(class IceInternal::BasicStream *,class IceInternal::ProxyHandle<class IceProxy::PLDBServer> &)" (?__read@@YAXPAVBasicStream@IceInternal@@2@@Z) already defin
    ed in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl __write(class IceInternal::BasicStream *,class IceInternal::Handle<class PLDBServer> const &)" (?__write@@YAXPAVBasicStream@IceInternal@@2@@Z) already defined in DBWatcherThread
    .obj
    PLDBServer.obj : error LNK2005: "void __cdecl __writeObject(class IceInternal::Handle<class Ice::Stream> const &,class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class PLDBSe
    rver> const &)" (?__writeObject@@IceInternal@@ABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@2@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl ice_marshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &,class IceInternal::Handle<class PLDBServ
    er> const &)" (?ice_marshal@@YAXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@IceInternal@@4@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl ice_unmarshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &,class IceInternal::Handle<class PLDBSe
    rver> &)" (?ice_unmarshal@@YAXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@IceInternal@@4@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl ice_marshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &,class IceInternal::ProxyHandle<class Ice
    Proxy::PLDBServer> const &)" (?ice_marshal@@YAXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@IceInternal@@4@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "void __cdecl ice_unmarshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &,class IceInternal::ProxyHandle<class I
    ceProxy::PLDBServer> &)" (?ice_unmarshal@@YAXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@IceInternal@@4@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "public: bool __thiscall PLDBRequest::operator==(struct PLDBRequest const &)const " (??8PLDBRequest@@QBE_NABU0@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "public: bool __thiscall PLDBRequest::operator!=(struct PLDBRequest const &)const " (??9PLDBRequest@@QBE_NABU0@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "public: bool __thiscall PLDBRequest::operator<(struct PLDBRequest const &)const " (??MPLDBRequest@@QBE_NABU0@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "public: void __thiscall PLDBRequest::__write(class IceInternal::BasicStream *)const " (?__write@PLDBRequest@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "public: void __thiscall PLDBRequest::__read(class IceInternal::BasicStream *)" (?__read@PLDBRequest@@Z) already defined in DBWatcherThread.obj
    PLDBServer.obj : error LNK2005: "public: void __thiscall PLDBRequest::ice_marshal(class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > const &,class IceInternal::Handle<class Ice::Stream> const &)const " (?ice_ma
    rshal@PLDBRequest@@QBEXABV?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@Z) already defined in DBWatcherThread.obj
  • mes
    mes California
    John,

    These errors look pretty strange. If I didn't know better, I'd guess that DBWatcherThread.cpp was including a .cpp file where it should have been including a .h file. That's the only explanation I can find for the case where DBWatcherThread.obj contains definitions of Slice-generated functions for PLDBRequest types.

    If you still can't figure it out, you'll probably need to send us an archive with your files and VC project(s). Or, if you can't send us your code, send us a generic example that reproduces the same problem.

    - Mark
  • Hi Mark,

    You were right - sorry about that.

    I changed the include to the proper include file and now get 8 link errors.

    I think I know what these are I have the same struct defined in each Ice file. I'll change that and anticpate no problems.

    Thanks again and sorry for the typo.

    John
  • mes
    mes California
    Glad you figured it out!

    Have fun,
    - Mark