Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NetStream Class Reference

USAGE: NetStream mycli("in.cs.brown.edu", 21);. More...

#include <net.H>

Inheritance diagram for NetStream:

Inheritance graph
[legend]
Collaboration diagram for NetStream:

Collaboration graph
[legend]
List of all members.

Public Types

enum  StreamFlags {
  write = 0x1, read = 0x2, rw = 0x3, ascii = 0x4,
  ascii_w = 0x5, ascii_r = 0x6, ascii_rw = 0x7
}

Public Member Functions

 NetStream (int port, const char *name)
 NetStream (int fd, struct sockaddr_in *client, bool block=false)
 NetStream (Cstr_ptr &name, StreamFlags)
virtual ~NetStream ()
str_ptr name (void) const
str_ptr print_name (void) const
int port (void) const
int processing (void) const
Networknetwork (void) const
void subscribe (Cstr_ptr &t)
void subscribe (Cstr_list &t)
bool attached (void) const
void set_port (int p)
void add_network (Network *n)
void flush_data (void)
int read_stuff (void)
virtual void sample ()
void no_tcp_delay ()
void write (const char *const data, int count)
void read (UGAptr data, int count, int pop=1)
void flush ()
iostream * iostr () const
istream * istr () const
ostream * ostr () const
int ascii () const
char peekahead ()
void read_open_delim ()
void read_close_delim ()
void write_open_delim ()
void write_close_delim ()
void write_newline ()
void write_delim (char)
char read_delim ()
int check ()
int eof () const
void ws (char *)
STDbool operator! () const
STDbool fail () const
STDbool block () const
STDbool block (STDbool flag)
str_ptr get_string_with_spaces ()
virtual void reset ()
virtual void except ()
int fd ()

Static Public Member Functions

static void no_linger (int fd)

Protected Member Functions

void set_blocking (bool val) const
ssize_t write_to_net (const void *buf, size_t nbyte) const
ssize_t read_from_net (void *buf, size_t nbyte) const
int interpret (void)
virtual size_t recv (UGAptr, int)
virtual size_t send (const UGAptr data, int count)
void remove_me ()

Protected Attributes

STDmem_queue _in_queue
STDmem_queue _out_queue
iostream * _iostream
istream * _istream
ostream * _ostream
int _indent
int _fd

Private Member Functions

void _die (const char *msg)

Private Attributes

str_list tags_
str_ptr name_
int port_
int msgSize_
int processing_
str_ptr print_name_
Networknetwork_

Friends

class Network

Detailed Description

USAGE: NetStream mycli("in.cs.brown.edu", 21);.

Definition at line 54 of file net.H.


Member Enumeration Documentation

enum NetStream::StreamFlags
 

Enumerator:
write 
read 
rw 
ascii 
ascii_w 
ascii_r 
ascii_rw 

Definition at line 57 of file net.H.


Constructor & Destructor Documentation

NetStream::NetStream int  port,
const char *  name
 

Definition at line 425 of file net.C.

References _die(), FD_EVENT::_fd, STDdstream::block(), NetHost::get_address(), no_linger(), no_tcp_delay(), set_blocking(), and STD_FALSE.

Referenced by interpret().

NetStream::NetStream int  fd,
struct sockaddr_in *  client,
bool  block = false
 

Definition at line 456 of file net.C.

References FD_EVENT::_fd, STDdstream::block(), get_host_print_name(), NetHost::name(), name_, no_linger(), no_tcp_delay(), port_, print_name_, set_blocking(), and STD_FALSE.

NetStream::NetStream Cstr_ptr &  name,
StreamFlags 
 

Definition at line 490 of file net.C.

References FD_EVENT::_fd, STDdstream::_iostream, STDdstream::ascii(), STDdstream::block(), err_adv(), ERR_INCL_ERRNO, ERR_LEV_WARN, err_mesg(), err_msg(), err_ret(), Config::get_var_bool(), int(), read, set_blocking(), STD_FALSE, write, and write().

NetStream::~NetStream  )  [virtual]
 

Definition at line 600 of file net.C.

References FD_EVENT::_fd, STDdstream::_iostream, HANDLE(), port_, and set_blocking().


Member Function Documentation

void NetStream::_die const char *  msg  )  [private]
 

Definition at line 663 of file net.C.

References FD_EVENT::_fd, Config::get_var_bool(), name_, and port_.

Referenced by NetStream().

void NetStream::add_network Network n  )  [inline]
 

Definition at line 83 of file net.H.

References network_.

Referenced by DISTRIB::load(), and Network::Register().

int STDdstream::ascii  )  const [inline, inherited]
 

Definition at line 43 of file stream.H.

References STDdstream::istr(), and STDdstream::ostr().

Referenced by COMMENT::decode(), JOTdone::format(), STDdstream::get_string_with_spaces(), NetStream(), operator<<(), operator>>(), STDdstream::write_close_delim(), STDdstream::write_newline(), STDdstream::write_open_delim(), and STDdstream::ws().

bool NetStream::attached void   )  const [inline]
 

Definition at line 80 of file net.H.

References FD_EVENT::_fd, and STDdstream::iostr().

Referenced by DISTRIB::load_stream(), and DISTRIB::save_stream().

STDbool STDdstream::block STDbool  flag  )  [inline, inherited]
 

Definition at line 63 of file stream.H.

References STDdstream::_block.

STDbool STDdstream::block  )  const [inline, inherited]
 

Definition at line 62 of file stream.H.

References STDdstream::_block.

Referenced by NetStream(), and DISTRIB::save().

int STDdstream::check  )  [inline, inherited]
 

Definition at line 56 of file stream.H.

References STDdstream::peekahead().

Referenced by TAGformat::operator int(), and operator>>().

int STDdstream::eof  )  const [inline, inherited]
 

Definition at line 57 of file stream.H.

References STDdstream::_in_queue, STDmem_queue::count(), and STDdstream::istr().

Referenced by DISTRIB::interpret(), TAGformat::operator int(), and STDdstream::peekahead().

virtual void FD_EVENT::except  )  [inline, virtual, inherited]
 

Definition at line 47 of file tty.H.

STDbool STDdstream::fail  )  const [inline, inherited]
 

Definition at line 61 of file stream.H.

References STDdstream::_fail.

Referenced by STDdstream::peekahead(), and DISTRIB::save().

int FD_EVENT::fd  )  [inline, inherited]
 

Definition at line 48 of file tty.H.

References FD_EVENT::_fd.

Referenced by Network::connect_to(), interpret(), and WIN_MANAGER::tty_to_id::ready().

void STDdstream::flush  )  [inherited]
 

Definition at line 173 of file stream.C.

References STDdstream::_block, STDdstream::_fail, STDdstream::_out_queue, STDmem_queue::count(), STDmem_queue::get(), STDmem_queue::peek(), STDdstream::send(), STD_FALSE, and STD_TRUE.

Referenced by flush(), flush_data(), and STDdstream::write().

void NetStream::flush_data void   ) 
 

Definition at line 867 of file net.C.

References STDdstream::_out_queue, STDmem_queue::count(), STDdstream::flush(), Config::get_var_bool(), int(), packbuf, packbuf_space, packcount, UGA_PACK_WORD, and write_to_net().

Referenced by Network::flush_data().

str_ptr STDdstream::get_string_with_spaces  )  [inherited]
 

Definition at line 244 of file stream.C.

References STDdstream::ascii(), STDdstream::istr(), and j.

int NetStream::interpret void   )  [protected]
 

Definition at line 801 of file net.C.

References Network::_at_barrier, STDdstream::_in_queue, Network::add_stream(), brcase, brdefault, STDmem_queue::count(), FD_EVENT::fd(), Network::first_, Config::get_var_bool(), Network::interpret(), name(), NETadd_connection, NETbarrier, NETbroadcast, NETflush, NETidentify, NETquit, NetStream(), NETtext, network_, ARRAY< T >::num(), port(), print_name(), processing_, mem_push::remove_all(), Network::remove_stream(), set_port(), Network::streams_, and tags_.

Referenced by read_stuff().

iostream* STDdstream::iostr  )  const [inline, inherited]
 

Definition at line 39 of file stream.H.

References STDdstream::_iostream.

Referenced by attached().

istream* STDdstream::istr  )  const [inline, inherited]
 

Definition at line 40 of file stream.H.

References STDdstream::_iostream, and STDdstream::_istream.

Referenced by STDdstream::ascii(), COMMENT::decode(), STDdstream::eof(), STDdstream::get_string_with_spaces(), DISTRIB::load(), operator>>(), STDdstream::peekahead(), STDdstream::read_close_delim(), and STDdstream::read_open_delim().

str_ptr NetStream::name void   )  const [inline]
 

Definition at line 72 of file net.H.

References name_.

Referenced by Network::accept_stream(), interpret(), DISTRIB::load_stream(), IOManager::notify_postload(), IOManager::notify_postsave(), IOManager::notify_preload(), IOManager::notify_presave(), and set_port().

Network* NetStream::network void   )  const [inline]
 

Definition at line 76 of file net.H.

References network_.

Referenced by sample().

void NetStream::no_linger int  fd  )  [static]
 

Definition at line 784 of file net.C.

Referenced by Network::configure(), and NetStream().

void NetStream::no_tcp_delay  ) 
 

Definition at line 643 of file net.C.

References FD_EVENT::_fd, Config::get_var_bool(), and print_name().

Referenced by NetStream().

STDbool STDdstream::operator!  )  const [inline, inherited]
 

Definition at line 60 of file stream.H.

References STDdstream::_fail.

ostream* STDdstream::ostr  )  const [inline, inherited]
 

Definition at line 41 of file stream.H.

References STDdstream::_iostream, and STDdstream::_ostream.

Referenced by STDdstream::ascii(), operator<<(), and STDdstream::write_delim().

char STDdstream::peekahead  )  [inherited]
 

Definition at line 65 of file stream.C.

References STDdstream::_fail, STDdstream::eof(), STDdstream::fail(), STDdstream::istr(), STDdstream::read(), and STD_FALSE.

Referenced by STDdstream::check(), and DISTRIB::interpret().

int NetStream::port void   )  const [inline]
 

Definition at line 74 of file net.H.

References port_.

Referenced by JOTcreate::get(), interpret(), and set_port().

str_ptr NetStream::print_name void   )  const [inline]
 

Definition at line 73 of file net.H.

References print_name_.

Referenced by interpret(), DISTRIB::interpret(), and no_tcp_delay().

int NetStream::processing void   )  const [inline]
 

Definition at line 75 of file net.H.

References processing_.

Referenced by Network::processing().

void STDdstream::read UGAptr  data,
int  count,
int  pop = 1
[inherited]
 

Definition at line 123 of file stream.C.

References STDdstream::_block, STDdstream::_fail, STDdstream::_in_queue, STDmem_queue::count(), DSTREAM_READ_AHEAD_FACTOR, STDmem_queue::get(), STDmem_queue::peek(), STDmem_queue::put(), STDdstream::recv(), STD_FALSE, and STD_TRUE.

Referenced by operator>>(), STDdstream::peekahead(), and STDdstream::read_delim().

void STDdstream::read_close_delim  )  [inherited]
 

Definition at line 205 of file stream.C.

References STDdstream::istr(), and STDdstream::read_delim().

Referenced by TAGformat::read_end_id().

char STDdstream::read_delim  )  [inherited]
 

Definition at line 236 of file stream.C.

References STDdstream::read().

Referenced by operator>>(), STDdstream::read_close_delim(), and STDdstream::read_open_delim().

ssize_t NetStream::read_from_net void *  buf,
size_t  nbyte
const [protected]
 

Definition at line 675 of file net.C.

References FD_EVENT::_fd, Config::get_var_bool(), port_, read, and the_time().

Referenced by read_stuff().

void STDdstream::read_open_delim  )  [inherited]
 

Definition at line 216 of file stream.C.

References STDdstream::istr(), and STDdstream::read_delim().

Referenced by TAGformat::read_id().

int NetStream::read_stuff void   ) 
 

Definition at line 886 of file net.C.

References STDdstream::_in_queue, Config::get_var_bool(), int(), interpret(), msgSize_, packbuf, packbuf_space, STDmem_queue::put(), read_from_net(), and UGA_UNPACK_INTEGER.

Referenced by DISTRIB::load(), and sample().

virtual size_t NetStream::recv UGAptr  ,
int 
[inline, protected, virtual]
 

Reimplemented from STDdstream.

Definition at line 99 of file net.H.

void NetStream::remove_me  )  [protected]
 

Definition at line 637 of file net.C.

References network_, and Network::remove_stream().

virtual void FD_EVENT::reset  )  [inline, virtual, inherited]
 

Reimplemented in TabletMultimode.

Definition at line 46 of file tty.H.

void NetStream::sample  )  [virtual]
 

Implements FD_EVENT.

Definition at line 959 of file net.C.

References network(), read_stuff(), and Network::remove_stream().

virtual size_t NetStream::send const UGAptr  data,
int  count
[inline, protected, virtual]
 

Reimplemented from STDdstream.

Definition at line 101 of file net.H.

References write_to_net().

void NetStream::set_blocking bool  val  )  const [protected]
 

Definition at line 736 of file net.C.

References FD_EVENT::_fd, err_ret(), and Config::get_var_bool().

Referenced by NetStream(), write_to_net(), and ~NetStream().

void NetStream::set_port int  p  ) 
 

Definition at line 417 of file net.C.

References get_host_print_name(), name(), port(), port_, and print_name_.

Referenced by interpret().

void NetStream::subscribe Cstr_list &  t  )  [inline]
 

Definition at line 78 of file net.H.

References tags_.

void NetStream::subscribe Cstr_ptr &  t  )  [inline]
 

Definition at line 77 of file net.H.

References tags_.

Referenced by Network::add_stream(), and Network::subscribe().

void STDdstream::write const char *const   data,
int  count
[inherited]
 

Definition at line 98 of file stream.C.

References STDdstream::_block, STDdstream::_fail, STDdstream::_out_queue, STDdstream::flush(), STDmem_queue::put(), and STD_FALSE.

Referenced by operator<<(), and STDdstream::write_delim().

void STDdstream::write_close_delim  )  [inline, inherited]
 

Definition at line 50 of file stream.H.

References STDdstream::_indent, STDdstream::ascii(), and STDdstream::write_delim().

Referenced by TAGformat::end_id().

void STDdstream::write_delim char   )  [inherited]
 

Definition at line 227 of file stream.C.

References STDdstream::ostr(), and STDdstream::write().

Referenced by operator<<(), STDdstream::write_close_delim(), and STDdstream::write_open_delim().

void STDdstream::write_newline  )  [inline, inherited]
 

Definition at line 51 of file stream.H.

References STDdstream::_indent, STDdstream::ascii(), and STDdstream::ws().

Referenced by DATA_ITEM::format(), and TAGformat::id().

void STDdstream::write_open_delim  )  [inline, inherited]
 

Definition at line 49 of file stream.H.

References STDdstream::_indent, STDdstream::ascii(), and STDdstream::write_delim().

Referenced by TAGformat::id().

ssize_t NetStream::write_to_net const void *  buf,
size_t  nbyte
const [protected]
 

Definition at line 761 of file net.C.

References FD_EVENT::_fd, set_blocking(), and write.

Referenced by flush_data(), and send().

void STDdstream::ws char *   )  [inherited]
 

Definition at line 729 of file stream.C.

References STDdstream::ascii().

Referenced by TAGformat::id(), and STDdstream::write_newline().


Friends And Related Function Documentation

friend class Network [friend]
 

Definition at line 55 of file net.H.


Member Data Documentation

int FD_EVENT::_fd [protected, inherited]
 

Definition at line 41 of file tty.H.

Referenced by _die(), attached(), TTYfd::clear(), TTYfd::close(), Network::configure(), TTYfd::deactivate(), TTYfd::drain(), FD_EVENT::fd(), TTYfd::get_flags(), NetStream(), no_tcp_delay(), TTYfd::nread(), TTYfd::open(), TTYfd::read_all(), read_from_net(), TTYfd::send_break(), set_blocking(), TTYfd::set_flags(), TTYfd::setup(), Network::wait_for_connect(), TTYfd::write(), write_to_net(), and ~NetStream().

STDmem_queue STDdstream::_in_queue [protected, inherited]
 

Definition at line 73 of file stream.H.

Referenced by STDdstream::eof(), interpret(), STDdstream::read(), read_stuff(), and STDdstream::send().

int STDdstream::_indent [protected, inherited]
 

Definition at line 78 of file stream.H.

Referenced by STDdstream::write_close_delim(), STDdstream::write_newline(), and STDdstream::write_open_delim().

iostream* STDdstream::_iostream [protected, inherited]
 

Definition at line 75 of file stream.H.

Referenced by STDdstream::iostr(), STDdstream::istr(), NetStream(), STDdstream::ostr(), and ~NetStream().

istream* STDdstream::_istream [protected, inherited]
 

Definition at line 76 of file stream.H.

Referenced by STDdstream::istr().

ostream* STDdstream::_ostream [protected, inherited]
 

Definition at line 77 of file stream.H.

Referenced by STDdstream::ostr().

STDmem_queue STDdstream::_out_queue [protected, inherited]
 

Definition at line 74 of file stream.H.

Referenced by STDdstream::flush(), flush_data(), STDdstream::recv(), and STDdstream::write().

int NetStream::msgSize_ [private]
 

Definition at line 112 of file net.H.

Referenced by read_stuff().

str_ptr NetStream::name_ [private]
 

Definition at line 110 of file net.H.

Referenced by _die(), name(), and NetStream().

Network* NetStream::network_ [private]
 

Definition at line 115 of file net.H.

Referenced by add_network(), interpret(), network(), and remove_me().

int NetStream::port_ [private]
 

Definition at line 111 of file net.H.

Referenced by _die(), NetStream(), port(), read_from_net(), set_port(), and ~NetStream().

str_ptr NetStream::print_name_ [private]
 

Definition at line 114 of file net.H.

Referenced by NetStream(), print_name(), and set_port().

int NetStream::processing_ [private]
 

Definition at line 113 of file net.H.

Referenced by interpret(), and processing().

str_list NetStream::tags_ [private]
 

Definition at line 109 of file net.H.

Referenced by interpret(), and subscribe().


The documentation for this class was generated from the following files:
Generated on Mon Sep 18 11:46:45 2006 for jot by  doxygen 1.4.4