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