2 * This file is part of the Nice GLib ICE library.
4 * (C) 2008-2009 Collabora Ltd.
5 * Contact: Youness Alaoui
6 * (C) 2008-2009 Nokia Corporation. All rights reserved.
8 * The contents of this file are subject to the Mozilla Public License Version
9 * 1.1 (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS" basis,
14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15 * for the specific language governing rights and limitations under the
18 * The Original Code is the Nice GLib ICE library.
20 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
21 * Corporation. All Rights Reserved.
24 * Youness Alaoui, Collabora Ltd.
26 * Alternatively, the contents of this file may be used under the terms of the
27 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
28 * case the provisions of LGPL are applicable instead of those above. If you
29 * wish to allow use of your version of this file only under the terms of the
30 * LGPL and not to allow others to use your version of this file under the
31 * MPL, indicate your decision by deleting the provisions above and replace
32 * them with the notice and other provisions required by the LGPL. If you do
33 * not delete the provisions above, a recipient may use your version of this
34 * file under either the MPL or the LGPL.
37 #ifndef _SOCKET_PRIV_H
38 #define _SOCKET_PRIV_H
45 * nice_socket_queue_send:
46 * @send_queue: The queue to add to
48 * @messages: Messages to queue
49 * @n_messages: Number of messages to queue
51 * Queue messages to be sent later into the GQueue
53 void nice_socket_queue_send (GQueue *send_queue, const NiceAddress *to,
54 const NiceOutputMessage *messages, guint n_messages);
57 * nice_socket_queue_send_with_callback:
58 * @send_queue: The queue to add to
59 * @message: The message to queue
60 * @message_offset: Number of bytes to skip in the message
61 * @message_len: Total length of the message
62 * @head: Whether to add the message to the head of the queue or the tail
63 * @gsock: The #GSocket to create the callback on
64 * @io_source: Pointer to #GSource pointer to store the created source
65 * @context: #GMainContext to attach the @io_source to
66 * @cb: Callback function to call when the @gsock is writable
67 * @user_data: User data for @cb
69 * Queue (partial) message to be sent later and create a source to call @cb
70 * when the @gsock becomes writable.
71 * The @message_offset can be used if a partial write happened and some bytes
72 * were already written, in which case @head should be set to TRUE to add the
73 * message to the head of the queue.
75 void nice_socket_queue_send_with_callback (GQueue *send_queue,
76 const NiceOutputMessage *message, gsize message_offset, gsize message_len,
77 gboolean head, GSocket *gsock, GSource **io_source, GMainContext *context,
78 GSocketSourceFunc cb, gpointer user_data);
81 * nice_socket_flush_send_queue:
82 * @base_socket: Base socket to send on
83 * @send_queue: Queue to flush
85 * Send all the queued messages reliably to the base socket. We assume only
86 * reliable messages were queued and the underlying socket will handle the
89 void nice_socket_flush_send_queue (NiceSocket *base_socket, GQueue *send_queue);
92 * nice_socket_flush_send_queue_to_socket:
93 * @gsock: GSocket to send on
94 * @send_queue: Queue to flush
96 * Send all the queued messages to the socket. If any message fails to be sent
97 * it will be readded to the queue and #FALSE will be returned, in which case
98 * the IO source must be kept to allow flushing the next time the socket
100 * If the queue gets flushed, #TRUE will be returned, in which case, the IO
101 * source should be destroyed.
103 * Returns: #TRUE if the queue was emptied, #FALSE if the socket would block.
105 gboolean nice_socket_flush_send_queue_to_socket (GSocket *gsock,
109 * nice_socket_free_send_queue:
110 * @send_queue: The send queue
112 * Frees every item in the send queue without sending them and empties the queue
114 void nice_socket_free_send_queue (GQueue *send_queue);
118 #endif /* _SOCKET_PRIV_H */