Commit 596e4f4b authored by Youness Alaoui's avatar Youness Alaoui Committed by Olivier Crête

Add a nice_socket_recv convenience function similar to nice_socket_send

parent a9ce3510
...@@ -195,6 +195,23 @@ nice_socket_send_messages_reliable (NiceSocket *sock, const NiceAddress *to, ...@@ -195,6 +195,23 @@ nice_socket_send_messages_reliable (NiceSocket *sock, const NiceAddress *to,
return sock->send_messages_reliable (sock, to, messages, n_messages); 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 /* 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 * bytes sent on success (which will be @len), zero if sending would block, or
* -1 on error. */ * -1 on error. */
......
...@@ -99,7 +99,10 @@ gint ...@@ -99,7 +99,10 @@ gint
nice_socket_send_messages_reliable (NiceSocket *sock, const NiceAddress *addr, nice_socket_send_messages_reliable (NiceSocket *sock, const NiceAddress *addr,
const NiceOutputMessage *messages, guint n_messages); const NiceOutputMessage *messages, guint n_messages);
gssize 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); const gchar *buf);
gssize gssize
nice_socket_send_reliable (NiceSocket *sock, const NiceAddress *addr, gsize len, nice_socket_send_reliable (NiceSocket *sock, const NiceAddress *addr, gsize len,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment