Merge "Initial docs skeleton"
[it/test.git] / ons_2019_demo / load_consumer / dummy_rcvr.c
1 /*
2  *
3  * Copyright 2019 AT&T Intellectual Property
4  * Copyright 2019 Nokia
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19  
20 // :vim ts=4 sw=4 noet:
21 /*
22         Mnemonic:       dummy_rcvr.c
23         Abstract:       RMr receiver that discards everything.
24
25                                 Define these environment variables to have some control:
26                                         RMR_SEED_RT -- path to the static routing table
27                                         RMR_RTG_SVC -- host:port of the route table generator
28
29         Date:           24 March 2019
30         Author:         E. Scott Daniels
31
32         Mods:
33 */
34
35 #include <unistd.h>
36 #include <errno.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <time.h>
40
41 #include <rmr/rmr.h>
42
43 int main( int argc, char** argv ) {
44     void* mrc;                                          // msg router context
45     rmr_mbuf_t* msg = NULL;                             // message received
46         int i;
47         char*   listen_port;
48         int             count = 0;
49
50         if( (listen_port = getenv( "DUMMY_RCVR_PORT" )) == NULL ) {
51                 listen_port = "19289";
52         }
53
54     mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE );       // start your engines!
55         if( mrc == NULL ) {
56                 fprintf( stderr, "<RCVR> ABORT:  unable to initialise RMr\n" );
57                 exit( 1 );
58         }
59
60         while( ! rmr_ready( mrc ) ) {
61                 fprintf( stderr, "<RCVR> waiting for RMr to show ready\n" );
62                 sleep( 1 );
63         }
64         fprintf( stderr, "<RCVR> RMr now shows ready\n" );
65
66         fprintf( stderr, "<RCVR> listening on %s build=%s @ %s\n", listen_port, __DATE__, __TIME__  );
67
68     while( 1 ) {
69                 msg = rmr_rcv_msg( mrc, msg );                                          // block until one arrives
70                 count++;
71                 //if( count % 1000 == 0 ) {
72                         fprintf( stderr, "receiver received: %d\n", count );
73                 //}
74     }
75 }