[asycxx-devel] SF.net SVN: asycxx:[41] trunk
Status: Alpha
Brought to you by:
joe_steeve
From: <joe...@us...> - 2009-04-08 07:42:24
|
Revision: 41 http://asycxx.svn.sourceforge.net/asycxx/?rev=41&view=rev Author: joe_steeve Date: 2009-04-08 07:42:19 +0000 (Wed, 08 Apr 2009) Log Message: ----------- refactored class:TCPLLTransport * changes to support changes in TCPTransport * moved class:TCPLLTransport to 'asycxx' namespace From: Joe Steeve <js...@hi...> Modified Paths: -------------- trunk/include/asycxx/TCPLLTransport.h trunk/src/TCPLLTransport.cxx Modified: trunk/include/asycxx/TCPLLTransport.h =================================================================== --- trunk/include/asycxx/TCPLLTransport.h 2009-04-08 07:41:32 UTC (rev 40) +++ trunk/include/asycxx/TCPLLTransport.h 2009-04-08 07:42:19 UTC (rev 41) @@ -18,17 +18,47 @@ #include "Reactor.h" #include "TCPTransport.h" -class TCPLLTransport : public TCPTransport +namespace asycxx { -public: - TCPLLTransport (Reactor *reactor, int fd); - virtual ~TCPLLTransport (); + class TCPLLTransport : public TCPTransport + { + public: + TCPLLTransport (Reactor *reactor, int fd); + virtual ~TCPLLTransport () {} + + /** + * \brief set the socket as TCP_NODELAY + * + * \details This method disables the Nagle algorithm on the connection + * by setting TCP_NODELAY. + */ + void configureTCPLLNoDelay (void); - void configureTCPLLNoDelay (void); - void configureTCPLLKeepAlive (int idle_time, int probe_count, - int probe_interval); -}; + /** + * \brief Configure the TCP keepalive mechanism + * + * \param[in] idle_time Idle time (time in which no data came + * across the wire) in seconds to wait for the keep-alive + * mechanism to kick in. + * \param[in] probe_count Number of keep-alive probes to send to + * the other end before deciding that the other-end is dead. + * \param[in] probe_interval The time in seconds between each + * keep-alive probe. + * + * \details This method configure's the TCP keepalive + * mechanism. This method is provided so that the user of this + * transport can tweak the keep-alive mechanism to see network + * errors faster. The maximum time taken before an error is + * noticed is + * + * idle_time + (probe_count * (probe_interval - 1)) + */ + void configureTCPLLKeepAlive (int idle_time, int probe_count, + int probe_interval); + }; +} + #endif /* __HIPRO_ASYCXX__TCP_LL_TRANSPORT_H__ */ /* Modified: trunk/src/TCPLLTransport.cxx =================================================================== --- trunk/src/TCPLLTransport.cxx 2009-04-08 07:41:32 UTC (rev 40) +++ trunk/src/TCPLLTransport.cxx 2009-04-08 07:42:19 UTC (rev 41) @@ -27,6 +27,7 @@ #include <asycxx/Protocol.h> #include <asycxx/TCPLLTransport.h> +using namespace asycxx; TCPLLTransport::TCPLLTransport (Reactor *reactor, int fd) : TCPTransport (reactor, fd) @@ -36,51 +37,19 @@ } -TCPLLTransport::~TCPLLTransport () -{ -} - -/** - * \brief set the socket as TCP_NODELAY - * - * \details This method disables the Nagle algorithm on the connection - * by setting TCP_NODELAY. - */ +/* setup tcp-no-delay */ void TCPLLTransport::configureTCPLLNoDelay (void) { - ASSERT ((m_Fd != -1), "sanity checks"); - int iret; int optval = 1; - iret = setsockopt (m_Fd, IPPROTO_TCP, TCP_NODELAY, (void *)&optval, + iret = setsockopt (Fd(), IPPROTO_TCP, TCP_NODELAY, (void *)&optval, sizeof (optval)); - if (iret == -1) - { - THROW (RunTimeError, "setting up TCP_NODELAY on fd=%d failed with %s", - m_Fd, strerror (errno)); - } + ASSERT ((iret == 0), "setting up TCP_NODELAY on fd=%d failed with %s", + Fd(), strerror (errno)); } - -/** - * \brief Configure the TCP keepalive mechanism - * - * \param[in] idle_time Idle time (time in which no data came across - * the wire) in seconds to wait for the keep-alive mechanism to kick - * in. - * \param[in] probe_count Number of keep-alive probes to send to the - * other end before deciding that the other-end is dead. - * \param[in] probe_interval The time in seconds between each - * keep-alive probe. - * - * \details This method configure's the TCP keepalive mechanism. This - * method is provided so that the user of this transport can tweak the - * keep-alive mechanism to see network errors faster. The maximum time - * taken before an error is noticed is - * - * idle_time + (probe_count * (probe_interval - 1)) - */ +/* enable tcp-keep-alive */ void TCPLLTransport::configureTCPLLKeepAlive (int idle_time, int probe_count, int probe_interval) @@ -96,54 +65,30 @@ if (idle_time > 0) { optval = idle_time; - iret = setsockopt (m_Fd, IPPROTO_TCP, TCP_KEEPIDLE, + iret = setsockopt (Fd(), IPPROTO_TCP, TCP_KEEPIDLE, (void *)&optval, sizeof (optval)); - if (iret == -1) - { - if (errno == EBADF) - { THROW (BadFDError, - "setting up TCP_KEEPIDLE(%d) on fd=%d threw '%s'", - idle_time, m_Fd, strerror (errno)); } - THROW (RunTimeError, - "setting up TCP_KEEPIDLE(%d) on fd=%d threw '%s'", - idle_time, m_Fd, strerror (errno)); - } + ASSERT ((iret == 0), "setting up TCP_KEEPIDLE(%d) on fd=%d threw '%s'", + idle_time, Fd(), strerror (errno)); } /* setup TCP_KEEPCNT */ if (probe_count > 0) { optval = probe_count; - iret = setsockopt (m_Fd, IPPROTO_TCP, TCP_KEEPCNT, + iret = setsockopt (Fd(), IPPROTO_TCP, TCP_KEEPCNT, (void *)&optval, sizeof (optval)); - if (iret == -1) - { - if (errno == EBADF) - { THROW (BadFDError, - "setting up TCP_KEEPCNT(%d) on fd=%d threw '%s'", - probe_count, m_Fd, strerror (errno)); } - THROW (RunTimeError, - "setting up TCP_KEEPCNT(%d) on fd=%d threw '%s'", - probe_count, m_Fd, strerror (errno)); - } + ASSERT ((iret == 0), "setting up TCP_KEEPCNT(%d) on fd=%d threw '%s'", + probe_count, Fd(), strerror (errno)); } /* setup TCP_KEEPINTVL */ if (probe_interval > 0) { optval = probe_interval; - iret = setsockopt (m_Fd, IPPROTO_TCP, TCP_KEEPCNT, + iret = setsockopt (Fd(), IPPROTO_TCP, TCP_KEEPCNT, (void *)&optval, sizeof (optval)); - if (iret == -1) - { - if (errno == EBADF) - { THROW (BadFDError, - "setting up TCP_KEEPCNT(%d) on fd=%d threw '%s'", - probe_interval, m_Fd, strerror (errno)); } - THROW (RunTimeError, - "setting up TCP_KEEPCNT(%d) on fd=%d threw '%s'", - probe_interval, m_Fd, strerror (errno)); - } + ASSERT ((iret == 0), "setting up TCP_KEEPCNT(%d) on fd=%d threw '%s'", + probe_interval, Fd(), strerror (errno)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |