X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=examples%2Fsender.c;h=dd8a1e00c2539b27b1791ff1653acb3c8f2e2ea1;hb=2d9d6784b306047e94ca9816813e5007b00fd17e;hp=25bba73b1e458e20432e54abd3e70a4a0dd29c64;hpb=d52954976038217d6067bc6e8e83d0ca882f9b6b;p=ric-plt%2Flib%2Frmr.git diff --git a/examples/sender.c b/examples/sender.c index 25bba73..dd8a1e0 100644 --- a/examples/sender.c +++ b/examples/sender.c @@ -1,14 +1,14 @@ // :vim ts=4 sw=4 noet: /* ================================================================================== - Copyright (c) 2019 Nokia - Copyright (c) 2018-2019 AT&T Intellectual Property. + 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 + 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, @@ -47,11 +47,11 @@ #include int main( int argc, char** argv ) { - void* mrc; //msg router context - struct epoll_event events[1]; // list of events to give to epoll - struct epoll_event epe; // event definition for event to listen to - int ep_fd = -1; // epoll's file des (given to epoll_wait) - int rcv_fd; // file des that NNG tickles -- give this to epoll to listen on + void* mrc; //msg router context + struct epoll_event events[1]; // list of events to give to epoll + struct epoll_event epe; // event definition for event to listen to + int ep_fd = -1; // epoll's file des (given to epoll_wait) + int rcv_fd; // file des that NNG tickles -- give this to epoll to listen on int nready; // number of events ready for receive rmr_mbuf_t* sbuf; // send buffer rmr_mbuf_t* rbuf; // received buffer @@ -74,12 +74,12 @@ int main( int argc, char** argv ) { fprintf( stderr, " listen port: %s; mtype: %d; delay: %d\n", listen_port, mtype, delay ); - if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) { + if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) { fprintf( stderr, " unable to initialise RMr\n" ); exit( 1 ); } - rcv_fd = rmr_get_rcvfd( mrc ); // set up epoll things, start by getting the FD from MRr + rcv_fd = rmr_get_rcvfd( mrc ); // set up epoll things, start by getting the FD from MRr if( rcv_fd < 0 ) { fprintf( stderr, " unable to set up polling fd\n" ); exit( 1 ); @@ -88,10 +88,10 @@ int main( int argc, char** argv ) { fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno ); exit( 1 ); } - epe.events = EPOLLIN; - epe.data.fd = rcv_fd; + epe.events = EPOLLIN; + epe.data.fd = rcv_fd; - if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 ) { + if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 ) { fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) ); exit( 1 ); } @@ -105,7 +105,7 @@ int main( int argc, char** argv ) { fprintf( stderr, " rmr is ready\n" ); - while( 1 ) { // send messages until the cows come home + while( 1 ) { // send messages until the cows come home snprintf( sbuf->payload, 200, "count=%d received= %d ts=%lld %d stand up and cheer!", // create the payload count, rcvd_count, (long long) time( NULL ), rand() ); @@ -133,6 +133,6 @@ int main( int argc, char** argv ) { } usleep( delay ); - } + } }