From 2a984ca8648a9be38413f972d6f7c241d36f65ce Mon Sep 17 00:00:00 2001
From: jkaeber <jkaeber@wiback.org>
Date: Fri, 7 Dec 2007 13:25:13 +0000
Subject: [PATCH] Changed available() method according after chat whith Stefan.

---
 Socket/Protocols/Raw/TunTapSocketHandle.cc | 30 +++++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/Socket/Protocols/Raw/TunTapSocketHandle.cc b/Socket/Protocols/Raw/TunTapSocketHandle.cc
index c2ab04338..9e02d6fd7 100644
--- a/Socket/Protocols/Raw/TunTapSocketHandle.cc
+++ b/Socket/Protocols/Raw/TunTapSocketHandle.cc
@@ -69,15 +69,31 @@ prefix_ std::auto_ptr<senf::SocketProtocol> senf::TapProtocol::clone()
 }
 
 prefix_ unsigned senf::TapProtocol::available()
-    const
+  const
 {
-    if (! body().readable())
-        return 0;
-    ssize_t l = ::recv(body().fd(),0,0,MSG_PEEK | MSG_TRUNC);
-    if (l < 0)
-        throwErrno();
-    return l;
+  if (! body().readable())
+      return 0;
+  ssize_t l = ::recv(body().fd(),0,0,MSG_PEEK | MSG_TRUNC);
+  if (l < 0)
+      //throwErrno();
+      return 1588;
+  return l;
+}
+
+/*
+#include <linux/sockios.h> // for SIOCINQ / SIOCOUTQ
+
+prefix_ unsigned senf::TapProtocol::available()
+  const
+{
+  if (! body().readable())
+      return 0;
+  int n;
+  if (::ioctl(body().fd(),SIOCINQ,&n) < 0)
+      throwErrno();
+  return n;
 }
+*/
 
 prefix_ bool senf::TapProtocol::eof()
     const
-- 
GitLab