Technotes provide learning opportunites where we explore different computer related subjects at a more in depth level. The intent is to allow a medium where readers can move beyond "hello world" and discuss details around the meat of computer & information science subjects.

 

Technotes - Client-Server communications and Error Handling.

 

Overview.

Client Server programming has been around since the 80s. There is nothing particularily new here. However it is our belief that while most programmers "do" client-server programming not many understand or tend to think about the gory details required to program a mature or Hardened Application. Due to this trend in the industry many applications are increadibly brittle. They work while the operating environment is good and the load is low, and then fail when these conditions are no longer met.

Worse than this is the troubling situation where once a failure situation is encountered the application is not worked over into a Hardened application. The users complain about one failure use case, and the application developers look at the app and fix the one particular use case that failed. The development team will typically fail to evalutate the application oh a whole and fix the more complex problem of error handling once and for all. (Note that many factors play into this reality. Lack of time, lack of due dillegence, lack of interest by the user communicty, as well as preceved risk by both users and management typically make it a hard sell to go into existing apps and Harden them for fault tolerance and error handling related code issues.)

Confronting the issues

So what steps can we take to remediate such situations? Educate people. With a better understanding up front of design decisions that revolve around distributed computing systems in general, developers will be more empowered to understand the practical implications of decisions that are made at design time. With a bit of forsight as well as proper planning we can all strive to build better quality applications.

Client Server Review - Happy Path

A good start is for a quick review of the most basic building block of distributed computing. Client - Server communication. Lets take the most fundamental and basic messaging in an environment where the system behaves perfectly and no errors are encountered. In many IT shops this use case is fonldy referred to as "the Happy Path".

This use case has two distinct messaging components. The client application (program) initiates the converstaion by first establishing a connection to the server (application program). We discretely call this step out as we will elaborate on this further in future sections. Next the client then sends the server a message. No errors happen in the I/O and thus the server successfully obtains the message and processes it.

In the second phase of the conversation the server (application program) responds to the client application (program). After the message is received the communication pathway is typically closed down.

Results of the Exchange

At the end of the simple exchange of information we have illustrated there are traditionally 2 specific items of interest that are received by the client.

  1. The status of the exchange. Which in our happy path use case is a SUCCESS. In typical messaging, status codes are handled much like the return code from a function that returns an integer in any common place programming langugae. The return code can be utilized such that particular values mean specific things as we will see in future examples. In this case we can use a 0 to indicate that the message exchange was a success.
  2. The body of the response message. This is what we commonly referr to as the response message payload. After checking the status code, this is the content that the client is really interested in examining.