summaryrefslogtreecommitdiff
path: root/libavformat/network.h
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-06-01 19:38:57 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-06-04 14:56:52 +0200
commit9835abb6d63fb07613994ae90e72fef758149408 (patch)
treecba69659a7ae4c4b30dd7728862e5b150a368efc /libavformat/network.h
parent7c020e1ad37d27c9d5db4d714401f09c80e3cc44 (diff)
network: uniform ff_listen_bind and ff_listen_connect
Document the functions and have both use a millisecond timeout and check for interrupt.
Diffstat (limited to 'libavformat/network.h')
-rw-r--r--libavformat/network.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/libavformat/network.h b/libavformat/network.h
index 454ea29252..673427ab66 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -210,9 +210,38 @@ const char *ff_gai_strerror(int ecode);
int ff_is_multicast_address(struct sockaddr *addr);
+#define POLLING_TIME 100 /// Time in milliseconds between interrupt check
+
+/**
+ * Bind to a file descriptor and poll for a connection.
+ *
+ * @param fd First argument of bind().
+ * @param addr Second argument of bind().
+ * @param addrlen Third argument of bind().
+ * @param timeout Polling timeout in milliseconds.
+ * @param h URLContext providing interrupt check
+ * callback and logging context.
+ * @return A non-blocking file descriptor on success
+ * or an AVERROR on failure.
+ */
int ff_listen_bind(int fd, const struct sockaddr *addr,
- socklen_t addrlen, int timeout);
+ socklen_t addrlen, int timeout,
+ URLContext *h);
+
+/**
+ * Connect to a file descriptor and poll for result.
+ *
+ * @param fd First argument of connect(),
+ * will be set as non-blocking.
+ * @param addr Second argument of connect().
+ * @param addrlen Third argument of connect().
+ * @param timeout Polling timeout in milliseconds.
+ * @param h URLContext providing interrupt check
+ * callback and logging context.
+ * @return 0 on success, AVERROR on failure.
+ */
int ff_listen_connect(int fd, const struct sockaddr *addr,
socklen_t addrlen, int timeout,
URLContext *h);
+
#endif /* AVFORMAT_NETWORK_H */