in reply to Re: Re: Reblessing
in thread Reblessing

A lot of this depends on how you're talking to your server. I'm assuming that you're connecting to the server over some IP connection (presumably TCP). That means you're passing messages back and forth through some socket. These messages have to be defined somewhere, either for you or by you.

Now, if you're given a message set, you have to work within it (for the most part).

If you're designing the message set, you have to take into account the various types of servers you know about, as well as the various types of servers you haven't even thought of. This means that your message set has to be flexible enough to handle expansions.

I would recommend SNMP for this, but that's just me.

Now, you're also making a very big conceptual error - you are not asking the connection objects anything. They simply are there to facilitate communication. They do two things:

  1. Take a message object and convert it to hexstream, then send it down the socket
  2. Be told to harvest a message from a socket, read the hexstream, and convert it to a message object.
Oh, yes, there are two connection objects - one for the server and one for you.

Now, from the client point of view, you are simply sending messages down a pipe, waiting for a response, then reading the response. You simply do not care what's on the other end(s). From each side's end, there's a magical place on the other side of the connection that magically sends messages back.

Your client also has to know what to do if there's a given response. Now, this isn't saying that the client knows about a given server type ... not really. The client knows what to do if given a certain message. Think state machines.

For example, the following sequence happens:

  1. You send a message saying "What is your type?"
  2. You receive a response saying "Replication"
At this point, you would then send a series of messages, awaiting a response for each, to ask about connections and stable devices. If, on the other hand, you receive a response saying "Database", you would then ask about CPU load and the like.

Your client has to be intelligent enough to know about different server types, just like a human has to be intelligent enough to ask the right questions when it encounters different situations. (If you think about it for a moment, you'll understand what I'm talking about.)