Socket: fixed bug in readfrom where socklen was not set
[senf.git] / Socket / ReadWritePolicy.hh
index a35b570..24d5cea 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -26,8 +26,8 @@
     \todo ReadWritePolicy.test.cc
  */
 
-#ifndef HH_ReadWritePolicy_
-#define HH_ReadWritePolicy_ 1
+#ifndef HH_SENF_Socket_ReadWritePolicy_
+#define HH_SENF_Socket_ReadWritePolicy_ 1
 
 // Custom includes
 #include "SocketPolicy.hh"
@@ -59,14 +59,14 @@ namespace senf {
                                              \param[in] size size of buffer
                                              \returns number of bytes read */
 #       ifndef DOXYGEN
-        template <class Policy>
-        static unsigned readfrom(ClientSocketHandle<Policy> handle, char * buffer, unsigned size,
-                                 typename Policy::AddressingPolicy::Address & address,
+        template <class SPolicy>
+        static unsigned readfrom(ClientSocketHandle<SPolicy> handle, char * buffer, unsigned size,
+                                 typename SPolicy::AddressingPolicy::Address & address,
                                  typename IfCommunicationPolicyIs<
-                                     Policy,UnconnectedCommunicationPolicy>::type * = 0);
+                                     SPolicy,UnconnectedCommunicationPolicy>::type * = 0);
 #       else
-        template <class Policy>
-        static unsigned readfrom(ClientSocketHandle<Policy> handle, char * buffer, unsigned size,
+        template <class SPolicy>
+        static unsigned readfrom(ClientSocketHandle<SPolicy> handle, char * buffer, unsigned size,
                                  typename Policy::AddressingPolicy::Address & address);
                                         ///< read data from socket returning peer address
                                         /**< \param[in] handle socket handle to read from
@@ -78,7 +78,7 @@ namespace senf {
 
     private:
         static unsigned do_readfrom(FileHandle handle, char * buffer, unsigned size,
-                                    struct ::sockaddr * addr, socklen_t len);
+                                    struct ::sockaddr * addr, socklen_t * len);
     };
 
     /** \brief ReadPolicy for unreadable sockets
@@ -98,13 +98,13 @@ namespace senf {
     struct WriteablePolicy : public WritePolicyBase
     {
 #       ifndef DOXYGEN
-        template <class Policy>
-        static unsigned write(ClientSocketHandle<Policy> handle, char const * buffer, unsigned size,
+        template <class SPolicy>
+        static unsigned write(ClientSocketHandle<SPolicy> handle, char const * buffer, unsigned size,
                               typename IfCommunicationPolicyIs<
-                                  Policy,ConnectedCommunicationPolicy>::type * = 0);
+                                  SPolicy,ConnectedCommunicationPolicy>::type * = 0);
 #       else
-        template <class Policy>
-        static unsigned write(ClientSocketHandle<Policy> handle, char const * buffer, 
+        template <class SPolicy>
+        static unsigned write(ClientSocketHandle<SPolicy> handle, char const * buffer, 
                               unsigned size);
                                         ///< write data to socket
                                         /**< This member is only enabled if the socket uses
@@ -118,16 +118,16 @@ namespace senf {
                                              \returns number of bytes written */
 #       endif
 #       ifndef DOXYGEN
-        template <class Policy>
-        static unsigned writeto(ClientSocketHandle<Policy> handle,
+        template <class SPolicy>
+        static unsigned writeto(ClientSocketHandle<SPolicy> handle,
                                 typename boost::call_traits<
-                                    typename Policy::AddressingPolicy::Address>::param_type addr,
+                                    typename SPolicy::AddressingPolicy::Address>::param_type addr,
                                 char const * buffer, unsigned size,
                                 typename IfCommunicationPolicyIs<
-                                    Policy,UnconnectedCommunicationPolicy>::type * = 0);
+                                    SPolicy,UnconnectedCommunicationPolicy>::type * = 0);
 #       else
-        template <class Policy>
-        static unsigned writeto(ClientSocketHandle<Policy> handle,
+        template <class SPolicy>
+        static unsigned writeto(ClientSocketHandle<SPolicy> handle,
                                 typename Policy::AddressingPolicy::Address const & addr,
                                 char const * buffer, unsigned size);
                                         ///< write data to socket sending to given peer