summaryrefslogtreecommitdiff
path: root/socket
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2014-04-11 00:11:49 -0400
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2014-05-15 09:44:00 -0400
commit596e4f4b10ffea0a33e463e78dbd98d714caf536 (patch)
tree7cb343ffdb044d3c407a5da6788a97556bf8f09f /socket
parenta9ce3510732275d0cd554d8daffe2e3fe4d83fe5 (diff)
downloadlibnice-596e4f4b10ffea0a33e463e78dbd98d714caf536.tar.gz
Add a nice_socket_recv convenience function similar to nice_socket_send
Diffstat (limited to 'socket')
-rw-r--r--socket/socket.c17
-rw-r--r--socket/socket.h5
2 files changed, 21 insertions, 1 deletions
diff --git a/socket/socket.c b/socket/socket.c
index 8c78a42..a92d2d9 100644
--- a/socket/socket.c
+++ b/socket/socket.c
@@ -195,6 +195,23 @@ nice_socket_send_messages_reliable (NiceSocket *sock, const NiceAddress *to,
return sock->send_messages_reliable (sock, to, messages, n_messages);
}
+/* Convenience wrapper around nice_socket_recv_messages(). Returns the number of
+ * bytes received on success (which will be @len), zero if sending would block, or
+ * -1 on error. */
+gssize
+nice_socket_recv (NiceSocket *sock, NiceAddress *from, gsize len,
+ gchar *buf)
+{
+ GInputVector local_buf = { buf, len };
+ NiceInputMessage local_message = { &local_buf, 1, from, 0};
+ gint ret;
+
+ ret = sock->recv_messages (sock, &local_message, 1);
+ if (ret == 1)
+ return local_message.length;
+ return ret;
+}
+
/* Convenience wrapper around nice_socket_send_messages(). Returns the number of
* bytes sent on success (which will be @len), zero if sending would block, or
* -1 on error. */
diff --git a/socket/socket.h b/socket/socket.h
index c0b2600..d2aa7af 100644
--- a/socket/socket.h
+++ b/socket/socket.h
@@ -99,7 +99,10 @@ gint
nice_socket_send_messages_reliable (NiceSocket *sock, const NiceAddress *addr,
const NiceOutputMessage *messages, guint n_messages);
gssize
-nice_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len,
+nice_socket_recv (NiceSocket *sock, NiceAddress *from, gsize len,
+ gchar *buf);
+gssize
+nice_socket_send (NiceSocket *sock, const NiceAddress *to, gsize len,
const gchar *buf);
gssize
nice_socket_send_reliable (NiceSocket *sock, const NiceAddress *addr, gsize len,