Scopira
20080306
|
#include <netflow.h>
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 netaddr & | get_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_i & | print (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) | |
a network flow (TCP)
scopira::tool::netflow::netflow | ( | void | ) |
default constructor, you can open() later.
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).
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
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).
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?
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