21. November 2008

Simple Remote Procedure Call - TCP

SRPC-TCP is an extension to SRPC. It specifies the encoding of SRPC over TCP.
Rules:

  • The message format over plain TCP instead of HTTP is identical to the HTTP POST body.
  • A message is terminated by an empty line, in other words: 2 consecutive newlines.
  • Multiple SRPC messages may be sent over the same TCP connection in both directions.
  • Requests have a "Method" (can, but not has to be the first line).
  • Responses have a "Status" (can, but not has to be the first line).

Example:

  1. C: Method=GetQuote
  2. C: Symbol=GOOG
  3. C: Date=1969-07-21
  4. C:
  1. S: Status=1
  2. S: Average=123
  3. S: Low=121
  4. S: High=125
  5. S:

Options:

  • Events: messages may be sent in one direction without a response,
  • Streaming: multiple request messages may be sent back to back before the corresponding responses are received by the client,
  • Ordering: responses may be sent out of order (needs SrpcId, see below),
SrpcId:
Responses are associated with requests by a special key called SrpcId. If the SrpcId key/value pair is included in a request, then the response must include the same key/value pair without interpreting the value. The SrpcId helps to find the request for a response.

Example:

  1. C: Method=FirstRequest
  2. C: SrpcId=abc
  3. C:
  4. C: Method=SecondRequest
  5. C: SrpcId=def
  6. C:
  7. S: Status=1
  8. S: SrpcId=def
  9. S:
  10. S: Status=0
  11. S: Message=error
  12. S: SrpcId=abc
  13. S:

Keine Kommentare: