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

socket stream buffer class. More...

#include <socketstream.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
 

Public Member Functions

 BasicSocketStreambuf ()
 default constructor.
 
 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 (int ms)
 set the socket timeout.
 
int timeout () const
 get the current timeout in milliseconds.
 
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.
 
int _timeout = 30000
 timeout.
 
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

Constructor & Destructor Documentation

◆ BasicSocketStreambuf() [1/3]

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

default constructor.

◆ BasicSocketStreambuf() [2/3]

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

copy constructor.

Parameters
otherother object to copy.

◆ BasicSocketStreambuf() [3/3]

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.

◆ 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 >
int join::BasicSocketStreambuf< Protocol >::timeout ( ) const
inline

get the current timeout in milliseconds.

Returns
the current timeout.

◆ timeout() [2/2]

template<class Protocol >
void join::BasicSocketStreambuf< Protocol >::timeout ( int ms)
inline

set the socket timeout.

Parameters
mstimeout in milliseconds.

◆ 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 >
int join::BasicSocketStreambuf< Protocol >::_timeout = 30000
protected

timeout.


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