join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicSocketStreambuf< Protocol > Class Template Reference

socket stream buffer class. More...

#include <socket_stream.hpp>

Inheritance diagram for join::BasicSocketStreambuf< Protocol >:
Collaboration diagram for join::BasicSocketStreambuf< Protocol >:

Public Types

using Endpoint = typename Protocol::Endpoint
 
using Socket = typename Protocol::Socket
 
using TimePoint = typename Socket::TimePoint
 

Public Member Functions

 BasicSocketStreambuf ()
 default constructor.
 
 BasicSocketStreambuf (Socket &&socket)
 construct the socket stream buffer by moving an existing socket in.
 
 BasicSocketStreambuf (const BasicSocketStreambuf &other)=delete
 copy constructor.
 
BasicSocketStreambufoperator= (const BasicSocketStreambuf &other)=delete
 copy assignment operator.
 
 BasicSocketStreambuf (BasicSocketStreambuf &&other)
 move constructor.
 
BasicSocketStreambufoperator= (BasicSocketStreambuf &&other)
 move assignment operator.
 
virtual ~BasicSocketStreambuf ()
 destroy the socket stream buffer instance.
 
BasicSocketStreambufbind (const Endpoint &endpoint)
 assigns the specified endpoint to the socket.
 
BasicSocketStreambufconnect (const Endpoint &endpoint)
 make a connection to the given endpoint.
 
BasicSocketStreambufdisconnect ()
 shutdown the connection.
 
void close ()
 close the connection.
 
void timeout (std::chrono::nanoseconds timeout)
 set the socket timeout.
 
std::chrono::nanoseconds timeout () const
 get the current timeout duration.
 
TimePoint deadline () const noexcept
 get the deadline of an operation started now.
 
Socketsocket ()
 get the nested socket.
 

Protected Member Functions

virtual int_type underflow () override
 reads characters from the associated input sequence to the get area.
 
virtual int_type overflow (int_type c=traits_type::eof()) override
 writes characters to the associated output sequence from the put area.
 
virtual int_type sync () override
 synchronizes the buffers with the associated character sequence.
 

Protected Attributes

std::unique_ptr< char[]> _buf
 internal buffer.
 
std::chrono::nanoseconds _timeout = std::chrono::seconds (30)
 timeout, zero when the stream operations are not time bounded.
 
Socket _socket
 internal socket.
 

Static Protected Attributes

static const std::streamsize _bufsize = 4096
 internal buffer size.
 

Detailed Description

template<class Protocol>
class join::BasicSocketStreambuf< Protocol >

socket stream buffer class.

Member Typedef Documentation

◆ Endpoint

template<class Protocol >
using join::BasicSocketStreambuf< Protocol >::Endpoint = typename Protocol::Endpoint

◆ Socket

template<class Protocol >
using join::BasicSocketStreambuf< Protocol >::Socket = typename Protocol::Socket

◆ TimePoint

template<class Protocol >
using join::BasicSocketStreambuf< Protocol >::TimePoint = typename Socket::TimePoint

Constructor & Destructor Documentation

◆ BasicSocketStreambuf() [1/4]

template<class Protocol >
join::BasicSocketStreambuf< Protocol >::BasicSocketStreambuf ( )
inline

default constructor.

◆ BasicSocketStreambuf() [2/4]

template<class Protocol >
join::BasicSocketStreambuf< Protocol >::BasicSocketStreambuf ( Socket && socket)
inlineexplicit

construct the socket stream buffer by moving an existing socket in.

Parameters
socketsocket to move in.

◆ BasicSocketStreambuf() [3/4]

template<class Protocol >
join::BasicSocketStreambuf< Protocol >::BasicSocketStreambuf ( const BasicSocketStreambuf< Protocol > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ BasicSocketStreambuf() [4/4]

template<class Protocol >
join::BasicSocketStreambuf< Protocol >::BasicSocketStreambuf ( BasicSocketStreambuf< Protocol > && other)
inline

move constructor.

Parameters
otherother object to move.

◆ ~BasicSocketStreambuf()

template<class Protocol >
virtual join::BasicSocketStreambuf< Protocol >::~BasicSocketStreambuf ( )
inlinevirtual

destroy the socket stream buffer instance.

Member Function Documentation

◆ bind()

template<class Protocol >
BasicSocketStreambuf * join::BasicSocketStreambuf< Protocol >::bind ( const Endpoint & endpoint)
inline

assigns the specified endpoint to the socket.

Parameters
endpointendpoint to assign to the socket.
Returns
this on success, nullptr on failure.

◆ close()

template<class Protocol >
void join::BasicSocketStreambuf< Protocol >::close ( )
inline

close the connection.

Returns
this on success, nullptr on failure.

◆ connect()

template<class Protocol >
BasicSocketStreambuf * join::BasicSocketStreambuf< Protocol >::connect ( const Endpoint & endpoint)
inline

make a connection to the given endpoint.

Parameters
endpointendpoint to connect to.
Returns
this on success, nullptr on failure.

◆ deadline()

template<class Protocol >
TimePoint join::BasicSocketStreambuf< Protocol >::deadline ( ) const
inlinenoexcept

get the deadline of an operation started now.

Returns
the deadline, max when the stream operations are not time bounded.

◆ disconnect()

template<class Protocol >
BasicSocketStreambuf * join::BasicSocketStreambuf< Protocol >::disconnect ( )
inline

shutdown the connection.

Returns
this on success, nullptr on failure.

◆ operator=() [1/2]

template<class Protocol >
BasicSocketStreambuf & join::BasicSocketStreambuf< Protocol >::operator= ( BasicSocketStreambuf< Protocol > && other)
inline

move assignment operator.

Parameters
otherother object to assign.
Returns
current object.

◆ operator=() [2/2]

template<class Protocol >
BasicSocketStreambuf & join::BasicSocketStreambuf< Protocol >::operator= ( const BasicSocketStreambuf< Protocol > & other)
delete

copy assignment operator.

Parameters
otherother object to assign.
Returns
current object.

◆ overflow()

template<class Protocol >
virtual int_type join::BasicSocketStreambuf< Protocol >::overflow ( int_type c = traits_type::eof ())
inlineoverrideprotectedvirtual

writes characters to the associated output sequence from the put area.

Parameters
cthe character to store in the put area.
Returns
EOF on failure, some other value on success.

◆ socket()

template<class Protocol >
Socket & join::BasicSocketStreambuf< Protocol >::socket ( )
inline

get the nested socket.

Returns
the nested socket.

◆ sync()

template<class Protocol >
virtual int_type join::BasicSocketStreambuf< Protocol >::sync ( )
inlineoverrideprotectedvirtual

synchronizes the buffers with the associated character sequence.

Returns
EOF on failure, some other value on success.

◆ timeout() [1/2]

template<class Protocol >
std::chrono::nanoseconds join::BasicSocketStreambuf< Protocol >::timeout ( ) const
inline

get the current timeout duration.

Returns
the current timeout duration.

◆ timeout() [2/2]

template<class Protocol >
void join::BasicSocketStreambuf< Protocol >::timeout ( std::chrono::nanoseconds timeout)
inline

set the socket timeout.

Parameters
timeoutmaximum time granted to each stream operation, zero to remove the limit.

◆ underflow()

template<class Protocol >
virtual int_type join::BasicSocketStreambuf< Protocol >::underflow ( )
inlineoverrideprotectedvirtual

reads characters from the associated input sequence to the get area.

Returns
the value of the character pointed to by the get pointer after the call on success, EOF otherwise.

Member Data Documentation

◆ _buf

template<class Protocol >
std::unique_ptr<char[]> join::BasicSocketStreambuf< Protocol >::_buf
protected

internal buffer.

◆ _bufsize

template<class Protocol >
const std::streamsize join::BasicSocketStreambuf< Protocol >::_bufsize = 4096
staticprotected

internal buffer size.

◆ _socket

template<class Protocol >
Socket join::BasicSocketStreambuf< Protocol >::_socket
protected

internal socket.

◆ _timeout

template<class Protocol >
std::chrono::nanoseconds join::BasicSocketStreambuf< Protocol >::_timeout = std::chrono::seconds (30)
protected

timeout, zero when the stream operations are not time bounded.


The documentation for this class was generated from the following file: