File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ CZMQ_EXPORT zmsg_t *
4444CZMQ_EXPORT int
4545 zmsg_send (zmsg_t * * self_p , void * dest );
4646
47+ // Send (More) message to destination socket, and destroy the message after sending
48+ // it successfully. If the message has no frames, sends nothing but destroys
49+ // the message anyhow. Nullifies the caller's reference to the message (as
50+ // it is a destructor).
51+ CZMQ_EXPORT int
52+ zmsg_sendm (zmsg_t * * self_p , void * dest );
53+
4754// Return size of message, i.e. number of frames (0 or more).
4855CZMQ_EXPORT size_t
4956 zmsg_size (zmsg_t * self );
Original file line number Diff line number Diff line change @@ -149,6 +149,34 @@ zmsg_send (zmsg_t **self_p, void *dest)
149149 return rc ;
150150}
151151
152+ // --------------------------------------------------------------------------
153+ // Send (More) message to destination socket, and destroy the message after sending
154+ // it successfully. If the message has no frames, sends nothing but destroys
155+ // the message anyhow. Nullifies the caller's reference to the message (as
156+ // it is a destructor).
157+ CZMQ_EXPORT int
158+ zmsg_sendm (zmsg_t * * self_p , void * dest )
159+ {
160+ assert (self_p );
161+ assert (dest );
162+ zmsg_t * self = * self_p ;
163+
164+ int rc = 0 ;
165+ void * handle = zsock_resolve (dest );
166+ if (self ) {
167+ assert (zmsg_is (self ));
168+ zframe_t * frame = (zframe_t * ) zlist_pop (self -> frames );
169+ while (frame ) {
170+ rc = zframe_send (& frame , handle ,ZFRAME_MORE );
171+ if (rc != 0 )
172+ break ;
173+ frame = (zframe_t * ) zlist_pop (self -> frames );
174+ }
175+ if (rc == 0 )
176+ zmsg_destroy (self_p );
177+ }
178+ return rc ;
179+ }
152180
153181// --------------------------------------------------------------------------
154182// Return size of message, i.e. number of frames (0 or more).
You can’t perform that action at this time.
0 commit comments