00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00029 #ifndef HH_SENF_Socket_ReadWritePolicy_
00030 #define HH_SENF_Socket_ReadWritePolicy_ 1
00031
00032
00033 #include "SocketPolicy.hh"
00034 #include "ClientSocketHandle.hh"
00035 #include "CommunicationPolicy.hh"
00036
00037
00038
00039
00040
00041 struct sockaddr;
00042
00043 namespace senf {
00044
00046
00047
00053 struct ReadablePolicy : public ReadPolicyBase
00054 {
00055 static unsigned read(FileHandle & handle, char * buffer, unsigned size);
00057
00061 # ifndef DOXYGEN
00062 template <class SPolicy>
00063 static unsigned readfrom(ClientSocketHandle<SPolicy> & handle, char * buffer, unsigned size,
00064 typename SPolicy::AddressingPolicy::Address & address,
00065 typename IfCommunicationPolicyIs<
00066 SPolicy,UnconnectedCommunicationPolicy>::type * = 0);
00067 # else
00068 template <class SPolicy>
00069 static unsigned readfrom(ClientSocketHandle<SPolicy> & handle, char * buffer, unsigned size,
00070 typename Policy::AddressingPolicy::Address & address);
00072
00077 # endif
00078
00079 private:
00080 static unsigned do_readfrom(FileHandle & handle, char * buffer, unsigned size,
00081 struct ::sockaddr * addr, socklen_t * len);
00082 };
00083
00090 struct NotReadablePolicy : public ReadPolicyBase
00091 {};
00092
00098 struct WriteablePolicy : public WritePolicyBase
00099 {
00100 # ifndef DOXYGEN
00101 template <class SPolicy>
00102 static unsigned write(ClientSocketHandle<SPolicy> & handle, char const * buffer, unsigned size,
00103 typename IfCommunicationPolicyIs<
00104 SPolicy,ConnectedCommunicationPolicy>::type * = 0);
00105 # else
00106 template <class SPolicy>
00107 static unsigned write(ClientSocketHandle<SPolicy> & handle, char const * buffer,
00108 unsigned size);
00110
00119 # endif
00120 # ifndef DOXYGEN
00121 template <class SPolicy>
00122 static unsigned writeto(ClientSocketHandle<SPolicy> & handle,
00123 typename boost::call_traits<
00124 typename SPolicy::AddressingPolicy::Address>::param_type addr,
00125 char const * buffer, unsigned size,
00126 typename IfCommunicationPolicyIs<
00127 SPolicy,UnconnectedCommunicationPolicy>::type * = 0);
00128 # else
00129 template <class SPolicy>
00130 static unsigned writeto(ClientSocketHandle<SPolicy> & handle,
00131 typename Policy::AddressingPolicy::Address const & addr,
00132 char const * buffer, unsigned size);
00134
00144 # endif
00145
00146 private:
00147 static unsigned do_write(FileHandle & handle, char const * buffer, unsigned size);
00148 static unsigned do_writeto(FileHandle & handle, char const * buffer, unsigned size,
00149 struct sockaddr const * addr, socklen_t len);
00150 };
00151
00158 struct NotWriteablePolicy : public WritePolicyBase
00159 {};
00160
00161
00162
00163 }
00164
00165
00166
00167
00168
00169 #include "ReadWritePolicy.cti"
00170 #endif
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181