XML

kent logo

CO538 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for server

2006

Question 104 (2006):

Submission reference: IN1177

Hi, I've been looking at last year's exam paper and came across the following question:

    (e)  Write a server loop that receives and processes one PACKET per loop
         from channel deliver. It must save payload data into suitably
         declared variables and process them in some way (leave blank lines in
         your code for this processing ... or use the ‘three-dots’ notation to
         indicate their position). The loop must terminate if poison is received.

Would the following be an acceptable answer to this?

    PROC server (CHAN PACKET deliver?)

      INT x:
      [1024]REAL64 y:
      INITIAL BOOL running IS TRUE:

      WHILE running
        deliver ? CASE
          BYTE size
          payload; x; size::y
            ...  deal with this variant
          poison
            running := false
    :

Thanks in advance.

Answer 104:

The protocol was declared in the previous part of this question:

    PROTOCOL PACKET
      payload; INT; BYTE::[]REAL64
      poison
    :

You would have scored the full (3) marks for your answer above. However, since the largest size value is 255, your array y is unnecessarily large. Also, the variables used for receiving the message should probably be localised just to the reception area – and their declarations, like all declarations, should end with a colon. For example:

    PROC server (CHAN PACKET deliver?)
      ...  local state (declarations and initialisation)
      WHILE running
        deliver ? CASE
          INT x:
          BYTE size:
          [255]REAL64 y:
          payload; x; size::y
            ...  deal with this variant
          poison
            running := false
    :

Keywords: protocol , server

Referrers: Question 66 (2007) , Question 66 (2007)

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:33 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.