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:
- C: Method=GetQuote
- C: Symbol=GOOG
- C: Date=1969-07-21
- C:
- S: Status=1
- S: Average=123
- S: Low=121
- S: High=125
- 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),
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:
- C: Method=FirstRequest
- C: SrpcId=abc
- C:
- C: Method=SecondRequest
- C: SrpcId=def
- C:
- S: Status=1
- S: SrpcId=def
- S:
- S: Status=0
- S: Message=error
- S: SrpcId=abc
- S:
Keine Kommentare:
Kommentar veröffentlichen