summaryrefslogtreecommitdiff
path: root/libavformat/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r--libavformat/tcp.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 0ed11f321f..37f74f6e2f 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -182,6 +182,22 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
return ret < 0 ? ff_neterrno() : ret;
}
+static int tcp_shutdown(URLContext *h, int flags)
+{
+ TCPContext *s = h->priv_data;
+ int how;
+
+ if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) {
+ how = SHUT_RDWR;
+ } else if (flags & AVIO_FLAG_WRITE) {
+ how = SHUT_WR;
+ } else {
+ how = SHUT_RD;
+ }
+
+ return shutdown(s->fd, how);
+}
+
static int tcp_close(URLContext *h)
{
TCPContext *s = h->priv_data;
@@ -202,6 +218,7 @@ URLProtocol ff_tcp_protocol = {
.url_write = tcp_write,
.url_close = tcp_close,
.url_get_file_handle = tcp_get_file_handle,
+ .url_shutdown = tcp_shutdown,
.priv_data_size = sizeof(TCPContext),
.flags = URL_PROTOCOL_FLAG_NETWORK,
};