From 9835abb6d63fb07613994ae90e72fef758149408 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 1 Jun 2013 19:38:57 +0200 Subject: network: uniform ff_listen_bind and ff_listen_connect Document the functions and have both use a millisecond timeout and check for interrupt. --- libavformat/network.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'libavformat/network.h') 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 */ -- cgit v1.2.3