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

Catching Exceptions

How do I go about catching exceptions.
For example, if I have a server that creates an object for a client.
so if the client does not invoke any of the functions, typically after the a preset timeout, the server will get a connectionlost exception. how do I actually capture this exception and all other exceptions (like memory limit Exception) at server side , in terms of ICEException value so that the server can do some actions.

how do I also know how many connections are there left for this object, if it sends to a few clients.


  • marc
    marc Florida
    You don't catch such exceptions on the server side. If a client closes a connection non-gracefully, then the server will simply print a warning, provided that you have have Ice.ConnectionWarnings set to a value > 0.

    You don't count connections from clients either. Client can open and close connections as they please, so connections are no indication for whether or not a client is alive.

    I think what you are looking for is session management, i.e., you have clients that connect to the server, and you want the server to clean up certain per-client objects once the client goes away. This can be done with Glacier2. Our first issue of our Connections newsletter has an article about this:
  • Catching Exception

    In that case, how about the memory exception. Remember my previous post on a very large file, like FTP? if I have such problem with the memory exception, how can the server know that an exception has occurred and move to contingency plan.

    Is there a way to calculate how much overhead ice uses. For example, if I set the Ice.MessageSizeMax to 1024. How much data can my class contain?
  • marc
    marc Florida
    Ice.MessageSizeMax is in KBytes. If it is set to 1024, you can send or receive data up to 1MB.

    I don't know what else I can answer other than that you cannot catch such exceptions on the server side. How do you think this should work? If the server returns a value, it gives back control to the ORB core. How could there be a catch block on a return statement?

    As an aside, if you transfer large files, you shouldn't do this with a single call. Instead, you should transfer the file in several chunks. For an example, have a look at IcePatch2.