Add root level docs control files
[ric-plt/lib/rmr.git] / doc / src / man / rmr_send_msg.3.xfm
1 .if false
2 ==================================================================================
3         Copyright (c) 2019 Nokia 
4         Copyright (c) 2018-2019 AT&T Intellectual Property.
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 .fi
19 .if false
20         Mnemonic        rmr_send_msg_man.xfm
21         Abstract        The manual page for the rmr_send_msg function.
22         Author          E. Scott Daniels
23         Date            28 January 2019
24 .fi
25
26 .gv e LIB lib
27 .im &{lib}/man/setup.im 
28
29 &line_len(6i)
30
31 &h1(RMR Library Functions)
32 &h2(NAME)
33         rmr_send_msg
34
35 &h2(SYNOPSIS )
36 &indent
37 &ex_start
38 #include <rmr/rmr.h>
39
40 rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg );
41 &ex_end
42 &uindent
43
44 &h2(DESCRIPTION)
45 The &cw(rmr_send_msg) function accepts a message buffer from the user application 
46 and attempts to send it.
47 The destination of the message is selected based on the message type specified
48 in the message buffer, and the matching information in the routing tables
49 which are currently in use by the RMR library. 
50 This may actually result in the sending of the message to multiple destinations
51 which could degrade expected overall performance of the user application. 
52 (Limiting excessive sending of messages is the responsibility of the application(s)
53 responsible for building the routing table used by the RMR library, and not the 
54 responsibility of the library.)
55
56
57 .** pull in common retry text
58 .im &{lib}/man/retry.im 
59
60
61 &h2(RETURN VALUE)
62 On success, a new message buffer, with an empty payload, is returned for the application
63 to use for the next send.
64 The state in this buffer will reflect the overall send operation state and should be
65 &cw(RMR_OK.)
66
67 &space
68 When the message cannot be successfully sent this function will return the unsent (original) 
69 message buffer with the state set to indicate the reason for failure.  
70 The value of &ital(errno) may also be set to reflect a more detailed failure reason if it
71 is known.
72
73 &space
74 In the event of extreme failure, a NULL pointer is returned. In this case the value of 
75 &cw(errno) might be of some use, for documentation, but there will be little that the 
76 user application can do other than to move on.
77
78 &h2(ERRORS)
79 The following values may be passed back in the &ital(state) field of the returned message
80 buffer. 
81
82 &space
83 &beg_dlist(.75i : ^&bold_font )
84 &di(RMR_RETRY)  The message could not be sent, but the underlying transport mechanism
85         indicates that the failure is temporary. If the send operation is tried again
86         it might be successful.
87 &di(RMR_SEND_FAILED) The send operation was not successful and the underlying transport
88         mechanism indicates a permanent (hard) failure; retrying the send is not possible.
89 &di(RMR_ERR_BADARG) The message buffer pointer did not refer to a valid message.
90 &di(RMR_ERR_NOHDR)  The header in the message buffer was not valid or corrupted.
91 &di(RMR_ERR_NOENDPT)  The message type in the message buffer did not map to a known endpoint.
92 &end_dlist
93
94 &space
95 The following values may be assigned to &cw(errno) on failure.
96 &beg_dlist(.75i : ^&bold_font )
97 &di(INVAL) Parameter(s) passed to the function were not valid, or the underlying message processing environment was unable to interpret the message.
98
99 &half_space
100 &di(ENOKEY) The header information in the message buffer was invalid.
101
102 &half_space
103 &di(ENXIO) No known endpoint for the message could be found.
104
105 &half_space
106 &di(EMSGSIZE) The underlying transport refused to accept the message because of a size value issue (message was not attempted to be sent).
107
108 &half_space
109 &di(EFAULT) The message referenced by the message buffer is corrupt (NULL pointer or bad internal length).
110
111 &half_space
112 &di(EBADF) Internal RMR error; information provided to the message transport environment was not valid.
113
114 &half_space
115 &di(ENOTSUP) Sending was not supported by the underlying message transport.
116
117 &half_space
118 &di(EFSM) The device is not in a state that can accept the message.
119
120 &half_space
121 &di(EAGAIN) The device is not able to accept a message for sending. The user application should attempt to resend.
122
123 &half_space
124 &di(EINTR) The operation was interrupted by delivery of a signal before the message was sent.
125
126 &half_space
127 &di(ETIMEDOUT) The underlying message environment timed out during the send process.
128
129 &half_space
130 &di(ETERM) The underlying message environment is in a shutdown state.
131 &end_dlist
132
133 &h2(EXAMPLE)
134 The following is a simple example of how the &cw(rmr_send_msg) function is called.
135 In this example, the send message buffer is saved between calls and reused
136 eliminating alloc/free cycles.
137
138 &space
139 &ex_start
140     static rmr_mbuf_t*  send_msg = NULL;        // message to send; reused on each call
141     msg_t*  send_pm;                            // payload for send
142     msg_t*  pm;                                 // our message format in the received payload
143
144         if( send_msg  == NULL ) {
145         send_msg = rmr_alloc_msg( mr, MAX_SIZE );       // new buffer to send
146         }
147
148         // reference payload and fill in message type
149     pm = (msg_t*) send_msg->payload;
150     send_msg->mtype = MT_ANSWER;                
151
152     msg->len = generate_data( pm );             // something that fills the payload in
153     msg = rmr_send_msg( mr, send_msg );
154         if( ! msg ) {
155                 return ERROR;
156         } else {
157                 if( msg->state != RMR_OK ) {
158                         // check for eagain, and resend if needed
159                         // else return error
160                 }
161         }
162
163         return OK;
164                         
165 &ex_end
166
167
168 &h2(SEE ALSO )
169 .ju off
170 rmr_alloc_msg(3),
171 rmr_call(3),
172 rmr_free_msg(3),
173 rmr_init(3),
174 rmr_payload_size(3),
175 rmr_rcv_msg(3),
176 rmr_rcv_specific(3),
177 rmr_rts_msg(3),
178 rmr_ready(3),
179 rmr_mk_ring(3),
180 rmr_ring_free(3),
181 rmr_torcv_rcv(3),
182 rmr_wh_send_msg(3)
183 .ju on
184