18 #ifndef HH_SENF_Socket_ClientSocketHandle_ 19 #define HH_SENF_Socket_ClientSocketHandle_ 1 22 #include <boost/call_traits.hpp> 23 #include <boost/range/iterator.hpp> 24 #include <boost/type_traits/is_convertible.hpp> 25 #include <boost/optional.hpp> 87 template <
class SPolicy>
96 typedef typename SPolicy::AddressingPolicy::Address
Address;
124 template <
class OtherPolicy>
132 template <
class OtherPolicy>
136 template <
class OtherPolicy>
177 std::string
read (
unsigned limit=0);
180 template <
class ForwardWritableRange>
181 typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned>,
182 typename boost::range_iterator<ForwardWritableRange>::type>::type
183 read(ForwardWritableRange
const & range);
185 template <
class ForwardWritableRange>
186 typename boost::range_iterator<ForwardWritableRange>::type
187 read (ForwardWritableRange
const & range);
202 template <
class ForwardWritableRange>
203 typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned>,
204 typename boost::range_iterator<ForwardWritableRange>::type>::type
205 read(ForwardWritableRange & range);
207 template <
class ForwardWritableRange>
208 typename boost::range_iterator<ForwardWritableRange>::type
209 read (ForwardWritableRange & range);
215 template <
class Sequence>
216 void read (Sequence & container,
unsigned limit);
225 char *
read (
char * start,
char * end);
252 std::pair<std::string, Address>
254 template <
class ForwardWritableRange>
255 typename boost::range_iterator<ForwardWritableRange const>::type
256 readfrom (ForwardWritableRange
const & range, Address & from);
271 template <
class ForwardWritableRange>
272 typename boost::range_iterator<ForwardWritableRange>::type
273 readfrom (ForwardWritableRange & range, Address & from);
278 template <
class Sequence>
279 void readfrom (Sequence & container, Address & from,
unsigned limit);
290 char *
readfrom (
char * start,
char * end, Address & from);
323 template <
class ForwardReadableRange>
324 typename boost::range_const_iterator<ForwardReadableRange const>::type
325 write (ForwardReadableRange
const & range);
326 char const *
write (
char const * start,
char const * end);
352 template <
class ForwardReadableRange>
353 typename boost::range_const_iterator<ForwardReadableRange const>::type
354 writeto (AddressParam addr, ForwardReadableRange
const & range);
355 char const *
writeto (AddressParam addr,
char const * start,
char const * end);
395 boost::optional<typename SPolicy::ReadPolicy::Buffer>
dequeue();
432 boost::optional<typename SPolicy::WritePolicy::Buffer>
enqueue();
453 void connect (AddressParam addr)
const;
464 void bind (AddressParam addr)
const;
477 Address
peer ()
const;
478 void peer (Address & addr)
const;
492 Address
local ()
const;
493 void local (Address & addr)
const;
503 void state(SocketStateMap & map,
unsigned lod=0);
bool send()
Send all data in the write queue.
ClientSocketHandle< OtherPolicy > const & operator=(ClientSocketHandle< OtherPolicy > other)
std::string dumpState(unsigned lod=0)
boost::call_traits< Address >::param_type AddressParam
'Best' type for passing address as parameter
boost::optional< typename SPolicy::ReadPolicy::Buffer > dequeue()
Read data from packet queue.
Generic SocketHandle with client interface.
Generic SocketHandle with server interface.
void state(SocketStateMap &map, unsigned lod=0)
static ClientSocketHandle cast_dynamic(FileHandle handle)
boost::optional< typename SPolicy::WritePolicy::Buffer > enqueue()
Write data to packet queue.
Basic file handle wrapper.
void bind(AddressParam addr) const
Set local address.
void connect(AddressParam addr) const
Connect to remote peer.
std::string read(unsigned limit=0)
Read data from socket.
boost::range_const_iterator< ForwardReadableRange const >::type writeto(AddressParam addr, ForwardReadableRange const &range)
Write data to unconnected socket.
void release()
Release all queue frames to the kernel.
basic SocketHandle supporting protocol and policy abstraction
Address local() const
Query local address.
static ClientSocketHandle cast_static(FileHandle handle)
SocketBody & body()
Access socket body.
Address peer() const
Query remote address.
SocketHandle public header.
Check policy compatibility.
SPolicy::AddressingPolicy::Address Address
Address type from the addressing policy.
boost::range_const_iterator< ForwardReadableRange const >::type write(ForwardReadableRange const &range)
Write data to socket.
std::pair< std::string, Address > readfrom(unsigned limit=0)
Read data from unconnected socket returning address.
ServerSocketHandle< SPolicy > ServerHandle
Corresponding server socket handle with the same policy.