summaryrefslogtreecommitdiff
path: root/agent/agent.h
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-01-16 15:45:12 +0000
committerOlivier Crête <olivier.crete@collabora.com>2014-01-31 01:49:07 -0500
commitdfab04cd8819f8244f783316c18642e49353c73e (patch)
treec2a48d62f82f7d41ffe268c7a896b063ce70a9b6 /agent/agent.h
parentbc527dcf63e9fb71e7432252a3371def265ba1e7 (diff)
socket: Add vectored I/O support for receiving on sockets
Replace the recv() API with a recv_messages() API, which supports receiving multiple messages, each with multiple buffers rather than a single monolithic buffer. This doesn’t break API, as the socket API is not exposed outside libnice. It does introduce a new struct: NiceInputMessage, which is analogous to struct mmsghdr. This includes updates to the test-bsd test to cover the changed API.
Diffstat (limited to 'agent/agent.h')
-rw-r--r--agent/agent.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/agent/agent.h b/agent/agent.h
index 5718479..2577fce 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -137,6 +137,40 @@ typedef struct _NiceAgent NiceAgent;
G_BEGIN_DECLS
+/**
+ * NiceInputMessage:
+ * @buffers: (array length=n_buffers): unowned array of #GInputVector buffers to
+ * store data in for this message
+ * @n_buffers: number of #GInputVectors in @buffers, or -1 to indicate @buffers
+ * is %NULL-terminated
+ * @from: (allow-none): return location to store the address of the peer who
+ * transmitted the message, or %NULL
+ * @length: total number of valid bytes contiguously stored in @buffers
+ *
+ * Represents a single message received off the network. For reliable
+ * connections, this is essentially just an array of buffers (specifically,
+ * @from can be ignored). for non-reliable connections, it represents a single
+ * packet as received from the OS.
+ *
+ * @n_buffers may be -1 to indicate that @buffers is terminated by a
+ * #GInputVector with a %NULL buffer pointer.
+ *
+ * By providing arrays of #NiceInputMessages to functions like
+ * nice_agent_recv_messages(), multiple messages may be received with a single
+ * call, which is more efficient than making multiple calls in a loop. In this
+ * manner, nice_agent_recv_messages() is analogous to recvmmsg(); and
+ * #NiceInputMessage to struct mmsghdr.
+ *
+ * Since: 0.1.5
+ */
+typedef struct {
+ GInputVector *buffers;
+ gint n_buffers; /* may be -1 to indicate @buffers is NULL-terminated */
+ NiceAddress *from; /* return location for address of message sender */
+ gsize length; /* sum of the lengths of @buffers */
+} NiceInputMessage;
+
+
#define NICE_TYPE_AGENT nice_agent_get_type()
#define NICE_AGENT(obj) \