Scopira  20080306
scopira::tool::netflow Class Reference

#include <netflow.h>

Inheritance diagram for scopira::tool::netflow:
scopira::tool::iflow_i scopira::tool::oflow_i scopira::tool::flow_i scopira::tool::flow_i scopira::tool::object scopira::tool::object

Public Types

enum  { tcp_nodelay_c = 1 }
 
- Public Types inherited from scopira::tool::flow_i
enum  { input_c = 1, output_c = 2 }
 
typedef scopira::tool::byte_t byte_t
 
typedef int mode_t
 

Public Member Functions

 netflow (void)
 
 netflow (const netaddr *_addr, int _port, int socket_options=0)
 
virtual ~netflow ()
 destructor
 
virtual bool failed (void) const
 are we in a failed state?
 
virtual size_t read (byte_t *_buf, size_t _maxsize)
 read raw block data, returns num read in
 
virtual size_t write (const byte_t *_buf, size_t _size)
 write a raw block of data
 
size_t read_short (byte_t *_buf, size_t _maxsize)
 
void open (const netaddr *_addr, int _port, int socket_options=0)
 
void close (void)
 close the file
 
bool accept (netflow &nconn)
 
bool read_ready (int msec)
 
const netaddrget_addr (void) const
 gets the address
 
int get_port (void) const
 gets the port
 
- Public Member Functions inherited from scopira::tool::iflow_i
virtual size_t read_byte (byte_t &out)
 
template<class TT >
size_t read_array (TT *_buf, size_t _numelem)
 
size_t read_void (void *_buf, size_t _maxsize)
 
- Public Member Functions inherited from scopira::tool::object
virtual ~object ()
 
int add_ref (void) const
 
bool sub_ref (void) const
 
void auto_ref (void) const
 
int current_ref (void) const
 
virtual scopira::tool::oflow_iprint (scopira::tool::oflow_i &o) const
 
virtual bool load (scopira::tool::iobjflow_i &in)
 
virtual void save (scopira::tool::oobjflow_i &out) const
 
bool is_alive_object (void) const
 
bool is_dead_object (void) const
 
- Public Member Functions inherited from scopira::tool::oflow_i
virtual size_t write_byte (byte_t b)
 
template<class TT >
size_t write_array (const TT *_buf, size_t _numelem)
 
size_t write_void (const void *_buf, size_t _size)
 

Protected Member Functions

void open_relay (socket_handle_t _fd, const flow_i::byte_t *_addr, int _addrlen, int _port)
 internal, used by server ::accept
 
- Protected Member Functions inherited from scopira::tool::object
 object (void)
 
 object (bool neverusecounter)
 

Detailed Description

a network flow (TCP)

Author
Aleksander Demko

Constructor & Destructor Documentation

◆ netflow() [1/2]

scopira::tool::netflow::netflow ( void  )

default constructor, you can open() later.

Author
Aleksander Demko

◆ netflow() [2/2]

scopira::tool::netflow::netflow ( const netaddr _addr,
int  _port,
int  socket_options = 0 
)

Openning ctor. _addr may be null for servers. The pointer is not used after this call returns. (ie. it can be a termporary).

Author
Aleksander Demko

Member Function Documentation

◆ accept()

bool scopira::tool::netflow::accept ( netflow nconn)

(for server), opens the given connection to the new link returns true if a new linke came in, false on error

◆ open()

void scopira::tool::netflow::open ( const netaddr _addr,
int  _port,
int  socket_options = 0 
)

Opens a client socket, null _addr for server socket The _addr object is not refered to after this call (ie. it can be a termporary).

Author
Aleksander Demko

◆ read_ready()

bool scopira::tool::netflow::read_ready ( int  msec)

is anything in the input buffer, within the given time? (false==timeout) 1000msec = 1 second

TODO: in the future, add a select() like thing for a bunch of them (and perhaps for fileflow too?) and udpflow, etc? common base class for read_read'able things?

Author
Aleksander Demko

◆ read_short()

size_t scopira::tool::netflow::read_short ( byte_t _buf,
size_t  _maxsize 
)

read raw block data, returns num read in this variant will return as soon as any data arrives though, so the return/read in size may often be less than _maxsize


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