diff options
author | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2014-04-11 00:11:49 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@ocrete.ca> | 2014-05-15 09:44:00 -0400 |
commit | 596e4f4b10ffea0a33e463e78dbd98d714caf536 (patch) | |
tree | 7cb343ffdb044d3c407a5da6788a97556bf8f09f /socket/socket.c | |
parent | a9ce3510732275d0cd554d8daffe2e3fe4d83fe5 (diff) | |
download | libnice-596e4f4b10ffea0a33e463e78dbd98d714caf536.tar.gz |
Add a nice_socket_recv convenience function similar to nice_socket_send
Diffstat (limited to 'socket/socket.c')
-rw-r--r-- | socket/socket.c | 17 |
1 files changed, 17 insertions, 0 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. */ |