home *** CD-ROM | disk | FTP | other *** search
- # fragment.m0
-
- # fragmentation procedure (cuts a messenger into messenger fragments)
- # usage: string int fragment array_of_strings
- # int is the maximum length a fragment can have
-
- # Note: this is a toy example because it assumes a reliable submission
- # channel (with en exactly-once transfer semantics, although messenger
- # fragments are allowed to arrive out of order).
- # A real fragmentation logic should be able to cope with fragment
- # loss and duplification.
- # Another limitation is that it can fail if more than 999 fragments
- # must be created.
-
-
- . 'fragment {
- D ( .X'mX: .X'sX:
- s`m>{
- .'a
- #includestring frag_0.m0
- :
- . 'm m a`- 30- : # header: 20, 2xinteger: 7, padding: 3
- . 'n s` m+1- m / :
- . 't n _cte " "+ :
- . 'k ; :
- [ n {
- [k t3I_cte+a+ s[0m s`>{s`}{m}?]G .'s s[4I`s`1I-]G: ]_ctm XP
- }L
- ]
- }{[s]}? )
- } :
-
-
- 'printF { P # define the test procedure only if the console is defined.
- # This test creates many fragments and submits them localy.
- # They reassemble themselves - the recreated final messenger
- # prints a hello msg on the console.
- .'test_fragment{
- [;
- "null0{}_cha'consoleG'_keyG!\"\x0aori=\"_ori _cte+\" (it worked!)\x0a\"+ $"
- 120S ]_ctm 150 fragment
- {['console 0 null] X $} L
- }:
- "file `fragment.m0' loaded\x0a" print
- }{}?
-