2011年5月30日 星期一

[Tips] Message Boundary

最近看文件看到message boundary這個名詞,突然愣了一下,經過東翻西找後,發現Richard Stevens大師寫的真清楚,以下節錄自UNIX Network Programming, Volume 2, Second Edition: Interprocess Communications

4.10 Streams and Message (p.67)
No record boundaries exist - reads and writes do not examine the data at all. The data is a byte stream with no interpretation done by the system. If any interpretation is desired, the writing process and the reading process must agree to it a priori and do it themselves.
1.Special termination sequence in-band: many Unix applications use the newline character to delineate each message.
2.Explicit length: each record is preceded by its length. One advantage to this technique is that escaping a delimiter that appears in the data is unnecessary, because the receiver does not need to scan all the data,looking for the end of each record.
3.One record per connection: the application closes the connection to its peer to indicate the end of a record. The requires a new connection for every record, but is used with HTTP 1.0.

只會用不會說果然不是真懂阿...

沒有留言: