Add missing send timeout man page
[ric-plt/lib/rmr.git] / doc / src / man / rmr_wh_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_wh_send_msg_man.xfm
21         Abstract        The manual page for the rmr_wh_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_wh_send_msg
45
46 &h2(SYNOPSIS )
47 &indent
48 &ex_start
49 #include <rmr/rmr.h>
50
51 rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t id, rmr_mbuf_t* msg );
52 &ex_end
53 &uindent
54
55 &h2(DESCRIPTION)
56 The &cw(rmr_wh_send_msg) function accepts a message buffer from the user application 
57 and attempts to send it using the wormhole ID provided (id).
58 Unlike &ital(rmr_send_msg,) this function attempts to send the message directly
59 to a process at the other end of a wormhole which was created with &ital(rmr_wh-open().)
60 When sending message via wormholes, the normal RMr routing based on message type is
61 ignored, and the caller may leave the message type unspecified in the message buffer
62 (unless it is needed by the receiving process).
63
64 .sp
65 The message buffer (msg) used to send is the same format as used for regular RMr 
66 send and reply to sender operations, thus any buffer allocated by these means, or
67 calls to &ital(rmr_rcv_msg()) can be passed to this function.
68
69 .** pull in common retry text
70 .im &{lib}/man/retry.im 
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 If the state in the returned buffer is anything other than &cw(RMR_OK,) the user application 
80 may need to attempt a retransmission of the message, or take other action depending on the
81 setting of &cw(errno) as described below. 
82
83 &space
84 In the event of extreme failure, a NULL pointer is returned. In this case the value of 
85 &cw(errno) might be of some use, for documentation, but there will be little that the 
86 user application can do other than to move on.
87
88 &h2(ERRORS)
89 The following values may be passed back in the &ital(state) field of the returned message
90 buffer. 
91
92 &space
93 &beg_dlist(.75i : ^&bold_font )
94 &di(RMR_ERR_WHID) The wormhole ID passed in was not associated with an open wormhole, or was out of range for a valid ID.
95 &di(RMR_ERR_NOWHOPEN) No wormholes exist, further attempt to validate the ID are skipped.
96 &di(RMR_ERR_BADARG) The message buffer pointer did not refer to a valid message.
97 &di(RMR_ERR_NOHDR)  The header in the message buffer was not valid or corrupted.
98 &end_dlist
99
100 &space
101 The following values may be assigned to &cw(errno) on failure.
102 &beg_dlist(.75i : ^&bold_font )
103 &di(INVAL) Parameter(s) passed to the function were not valid, or the underlying message processing environment was unable to interpret the message.
104
105 &half_space
106 &di(ENOKEY) The header information in the message buffer was invalid.
107
108 &half_space
109 &di(ENXIO) No known endpoint for the message could be found.
110
111 &half_space
112 &di(EMSGSIZE) The underlying transport refused to accept the message because of a size value issue (message was not attempted to be sent).
113
114 &half_space
115 &di(EFAULT) The message referenced by the message buffer is corrupt (NULL pointer or bad internal length).
116
117 &half_space
118 &di(EBADF) Internal RMR error; information provided to the message transport environment was not valid.
119
120 &half_space
121 &di(ENOTSUP) Sending was not supported by the underlying message transport.
122
123 &half_space
124 &di(EFSM) The device is not in a state that can accept the message.
125
126 &half_space
127 &di(EAGAIN) The device is not able to accept a message for sending. The user application should attempt to resend.
128
129 &half_space
130 &di(EINTR) The operation was interrupted by delivery of a signal before the message was sent.
131
132 &half_space
133 &di(ETIMEDOUT) The underlying message environment timed out during the send process.
134
135 &half_space
136 &di(ETERM) The underlying message environment is in a shutdown state.
137 &end_dlist
138
139 &h2(EXAMPLE)
140 The following is a simple example of how the a wormhole is created (rmr_wh_open) and then
141 how &cw(rmr_wh_send_msg) function is used to send messages.
142 Some error checking is omitted for clarity.
143
144 &space
145 &ex_start
146
147 #include <rmr/rmr.h>    // system headers omitted for clarity
148
149 int main() {
150    rmr_whid_t whid = -1;   // wormhole id for sending
151    void* mrc;      //msg router context
152         int i;
153    rmr_mbuf_t*  sbuf;      // send buffer
154    int     count = 0;
155
156    mrc = rmr_init( "43086", RMR_MAX_RCV_BYTES, RMRFL_NONE );
157    if( mrc == NULL ) {
158       fprintf( stderr, "[FAIL] unable to initialise RMr environment\n" );
159       exit( 1 );
160    }
161
162    while( ! rmr_ready( mrc ) ) {                // wait for routing table info
163       sleep( 1 );
164    }
165
166    sbuf = rmr_alloc_msg( mrc, 2048 );
167
168    while( 1 ) {
169      if( whid < 0 ) {
170        whid = rmr_wh_open( mrc, "localhost:6123" );  // open fails if endpoint refuses conn
171            if( RMR_WH_CONNECTED( wh ) ) { 
172            snprintf( sbuf->payload, 1024, "periodic update from sender: %d", count++ );
173            sbuf->len =  strlen( sbuf->payload );
174            sbuf = rmr_wh_send_msg( mrc, whid, sbuf );
175                 }
176          }
177
178          sleep( 5 );
179    }
180 }
181 &ex_end
182
183
184 &h2(SEE ALSO )
185 .ju off
186 rmr_alloc_msg(3),
187 rmr_call(3),
188 rmr_free_msg(3),
189 rmr_init(3),
190 rmr_payload_size(3),
191 rmr_rcv_msg(3),
192 rmr_rcv_specific(3),
193 rmr_rts_msg(3),
194 rmr_ready(3),
195 rmr_fib(3),
196 rmr_has_str(3),
197 rmr_tokenise(3),
198 rmr_mk_ring(3),
199 rmr_ring_free(3),
200 rmr_set_stimeout(3),
201 rmr_wh_open(3),
202 rmr_wh_close(3)
203 .ju on
204
205
206 .qu
207