This and the next use case will develop the basic communication patterns among the the object user, object broker, and object manager programs. This case will establish communication between the object broker and the object user, the next case will add communication between the object manager and the object broker, and case five will establish communication between a user and a manager through the broker. Use cases beyond that will implement more of the details of the CSSOOOBP protocol.
Request Type | Argument List | Return Value | Action |
---|---|---|---|
hello
| Anything | "Hello acknowledged" | Write a message to the log file that includes a unique name for the program that sent the request. See below for details. |
good-bye
| Anything | "Good-bye acknowledged" | Nothing |
list
| Anything | A string that includes the Argument List. Say something like, "List <Arg List> not implemented." in the string. | Nothing |
shutdown
| Anything | Nothing | Write a message to the log file that includes the Argument List as part of the message, then exit ob. |
In the next use case, the "hello" and "good-bye" requests will come from om, but for this use case, we will use ou to send them to ob. For this use case, you can use the same ou that you used in the previous cases, and om is not used at all.
The unique name for a program that is mentioned for "hello" requests is
to be in the form <hostname>:<port>, for example,
"jaguar:10F3". Given the sockaddr_in
struct that is
filled in by a call to recvfrom(), you can get the
<hostname> by calling gethostbyaddr() and the integer
value of remote program's port from the sin_port
field of
the sockaddr_in
struct.
In my implementation I used global variables for the <hostname>
and the sockaddr_in
struct because the call to
recvfrom() is in one part of the program (main()) and the
"hello" request is processed in a separate function whose prototype
allows only one string argument to be passed to it. You might be able
to think of a way to avoid this use of global variables cleanly.
The man page for ob, like the pages for other network servers, is oriented more towards users who need to know how to start and stop the server than for end-users. It would be appropriate to list the request types that ob recognizes and to tell what those requests would be used for. Don't describe the internal logic of ob, that should be done in the comments in the code.