Archived

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

new instance of server

Dear all,

Hi, sorry if it has been asked before ...
I 've created client and server app. with ICE. Because the nature of my application, I am thinking of creating new instance of server automatically by ICE, everytime there is a new client connection.
Somebody would argue to make new instance of an object in the server to server the client instead. However, we try to make the server as simple as possible (the client actually is the complicated one). Therefore we think our approach is the most simple one if it is judged by server code complexity.

Can somebody give me direction how to do it in ICE ?
Or is there any better approach for that?

Thanks

Widy
UbiAware
Cork, Ireland

Comments

  • benoit
    benoit Rennes, France
    Hi,

    I'm not sure I fully understand what you're trying to achieve. Do you want each client to have its own server instance? Or a same client to connect to multiple server instances for each request or object instance?

    In any case, there's no mechanism in Ice that allows spawning a new server in these scenarios. This is something you'll have to implement. For example, you could have a server to implement an object factory interface. Clients would call create() on the factory to create new objects. The implementation of create() would spawn a new server for each object and pass the proxy back to the client.

    Cheers,
    Benoit.
  • benoit wrote: »
    Hi,

    I'm not sure I fully understand what you're trying to achieve. Do you want each client to have its own server instance? Or a same client to connect to multiple server instances for each request or object instance?
    Cheers,
    Benoit.

    Each client to have its own server instance to be precise.
    Say, the server interface consist method of:
    int val;
    int foo()
    {
    val++;
    return val;
    }
    I want the server to remember value of "val" for each client and give respond to coresponding client invocation;
    For above example, of course, I can implement some kind of data structure (e.g. struct) which will remember client id and its last value.
    But if I use this approach, my real server implementation will be very complex.

    If server spawning is not inherently possible in IC, is it possible to make independent interface instance for each client instead?
  • matthew
    matthew NL, Canada
    It is possible to spawn new processes -- after all this is what IceGrid does :) However, we don't provide this functionality out of the box. You have to write this code yourself. However, I suspect this is not necessary for your application. You should examine what advantages a separate process will offer you. IMO, the key advantage for a separate process is separation of resources and additional operating system level security. If this isn't important for your application then I would recommend against this approach because it has significant disadvantages and is absolutely non-trivial to implement. If you want to go this route you can look at this FAQ http://www.zeroc.com/faq/fork.html for help.

    It is very simple to create a new object instances per-client. This is a typical session model where each client allocates a unique session object within the server. See, for example, demo/Ice/session. There are also numerous articles in our newsletter connections written on this subject.
  • Thanks Mathew ...
    I will look more at the session

    Thx