diff --git a/libavformat/tls.c b/libavformat/tls.c
index fb84fa82b680cca06a3e8dd1824c4ff479b4ded7..866e55f2baaf41e350ff5d91ced9ff65540682dc 100644
--- a/libavformat/tls.c
+++ b/libavformat/tls.c
@@ -209,7 +209,7 @@ static int tls_read(URLContext *h, uint8_t *buf, int size)
         if (ret > 0)
             return ret;
         if (ret == 0)
-            return AVERROR(EIO);
+            return AVERROR_EOF;
         if ((ret = do_tls_poll(h, ret)) < 0)
             return ret;
     }
@@ -224,7 +224,7 @@ static int tls_write(URLContext *h, const uint8_t *buf, int size)
         if (ret > 0)
             return ret;
         if (ret == 0)
-            return AVERROR(EIO);
+            return AVERROR_EOF;
         if ((ret = do_tls_poll(h, ret)) < 0)
             return ret;
     }