X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=doc%2Fsrc%2Flibrary%2Fcode_rcv.im;fp=doc%2Fsrc%2Flibrary%2Fcode_rcv.im;h=8d75d62bfce4f55cc5cb505a75a110a8b5ba97f8;hb=06e85b7015b6804e641424a022d0a9ceb282e280;hp=0000000000000000000000000000000000000000;hpb=f68c2ced7de2bdfc475a9282cde91a67d83325de;p=ric-plt%2Flib%2Frmr.git diff --git a/doc/src/library/code_rcv.im b/doc/src/library/code_rcv.im new file mode 100644 index 0000000..8d75d62 --- /dev/null +++ b/doc/src/library/code_rcv.im @@ -0,0 +1,52 @@ + +.if false +================================================================================== + Copyright (c) 2019 Nokia + Copyright (c) 2018-2019 AT&T Intellectual Property. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +.fi + +.** example sender code + +&h2(Receiver Sample) +The receiver code is even more simple than the sender code as it does not +need to wait for a route table to arrive (only senders need to do that), nor +does it need to allocate an initial buffer. +The example assumes that the sender is transmitting a zero terminated string +as the payload. + +&space + +&indent +&ex_start +rmr_mbuf_t* rbuf = NULL; +void* mrc = rmr_init( listen_port, MAX_BUF_SZ, RMRFL_NOFLAGS ); + +while( TRUE ) { + rbuf = rmr_rcv_msg( mrc, rbuf ); // reuse buffer on all but first loop + if( rbuf == NULL || rbuf->state != RMR_OK ) { + break; + } + + fprintf( stdout, "mtype=%d sid=%d pay=%s\n", + rbuf->mtype, rbuf->sub_id, rbuf->payload ); + sleep( delay_sec ); +} + +fprintf( stderr, "receive error\n" ); +rmr_close( mrc ); + +&ex_end +&uindent