Rudiments
Public Member Functions
modemserver Class Reference

Inherits server, and modemutil.

List of all members.

Public Member Functions

 modemserver ()
 modemserver (const modemserver &m)
modemserveroperator= (const modemserver &m)
virtual ~modemserver ()
bool listen (const char *device, const char *baud, const char *listenscript, const char *acceptscript, const char *disconnectscript)
void initialize (const char *device, const char *baud, const char *listenscript, const char *acceptscript, const char *disconnectscript)
bool bind ()
bool listen (int32_t backlog)
filedescriptoraccept ()
bool close ()
- Public Member Functions inherited from server
 server ()
 server (const server &s)
serveroperator= (const server &s)
virtual ~server ()
- Public Member Functions inherited from filedescriptor
 filedescriptor ()
 filedescriptor (const filedescriptor &f)
filedescriptoroperator= (const filedescriptor &f)
virtual ~filedescriptor ()
int32_t getFileDescriptor () const
void setFileDescriptor (int32_t filedesc)
int32_t duplicate () const
bool duplicate (int32_t newfd) const
virtual bool useNonBlockingMode () const
virtual bool useBlockingMode () const
bool isUsingNonBlockingMode () const
ssize_t write (uint16_t number) const
ssize_t write (uint32_t number) const
ssize_t write (uint64_t number) const
ssize_t write (int16_t number) const
ssize_t write (int32_t number) const
ssize_t write (int64_t number) const
ssize_t write (float number) const
ssize_t write (double number) const
ssize_t write (unsigned char character) const
ssize_t write (char character) const
ssize_t write (bool value) const
ssize_t write (const unsigned char *string) const
ssize_t write (const char *string) const
ssize_t write (const unsigned char *string, size_t size) const
ssize_t write (const char *string, size_t size) const
ssize_t write (const void *buffer, size_t size) const
ssize_t write (uint16_t number, long sec, long usec) const
ssize_t write (uint32_t number, long sec, long usec) const
ssize_t write (uint64_t number, long sec, long usec) const
ssize_t write (int16_t number, long sec, long usec) const
ssize_t write (int32_t number, long sec, long usec) const
ssize_t write (int64_t number, long sec, long usec) const
ssize_t write (float number, long sec, long usec) const
ssize_t write (double number, long sec, long usec) const
ssize_t write (unsigned char character, long sec, long usec) const
ssize_t write (char character, long sec, long usec) const
ssize_t write (bool value, long sec, long usec) const
ssize_t write (const unsigned char *string, long sec, long usec) const
ssize_t write (const char *string, long sec, long usec) const
ssize_t write (const unsigned char *string, size_t size, long sec, long usec) const
ssize_t write (const char *string, size_t size, long sec, long usec) const
ssize_t write (const void *buffer, size_t size, long sec, long usec) const
ssize_t read (uint16_t *buffer) const
ssize_t read (uint32_t *buffer) const
ssize_t read (uint64_t *buffer) const
ssize_t read (int16_t *buffer) const
ssize_t read (int32_t *buffer) const
ssize_t read (int64_t *buffer) const
ssize_t read (float *buffer) const
ssize_t read (double *buffer) const
ssize_t read (unsigned char *buffer) const
ssize_t read (char *buffer) const
ssize_t read (bool *buffer) const
ssize_t read (unsigned char *buffer, size_t size) const
ssize_t read (char *buffer, size_t size) const
ssize_t read (void *buf, size_t size) const
ssize_t read (char **buffer, const char *terminator) const
ssize_t read (uint16_t *buffer, long sec, long usec) const
ssize_t read (uint32_t *buffer, long sec, long usec) const
ssize_t read (uint64_t *buffer, long sec, long usec) const
ssize_t read (int16_t *buffer, long sec, long usec) const
ssize_t read (int32_t *buffer, long sec, long usec) const
ssize_t read (int64_t *buffer, long sec, long usec) const
ssize_t read (float *buffer, long sec, long usec) const
ssize_t read (double *buffer, long sec, long usec) const
ssize_t read (unsigned char *buffer, long sec, long usec) const
ssize_t read (char *buffer, long sec, long usec) const
ssize_t read (bool *buffer, long sec, long usec) const
ssize_t read (unsigned char *buffer, size_t size, long sec, long usec) const
ssize_t read (char *buffer, size_t size, long sec, long usec) const
ssize_t read (void *buf, size_t size, long sec, long usec) const
ssize_t read (char **buffer, const char *terminator, long sec, long usec) const
int32_t waitForNonBlockingRead (long sec, long usec) const
int32_t waitForNonBlockingWrite (long sec, long usec) const
void retryInterruptedReads ()
void dontRetryInterruptedReads ()
void retryInterruptedWrites ()
void dontRetryInterruptedWrites ()
void retryInterruptedWaits ()
void dontRetryInterruptedWaits ()
void retryInterruptedFcntl ()
void dontRetryInterruptedFcntl ()
void retryInterruptedIoctl ()
void dontRetryInterruptedIoctl ()
void allowShortReads ()
void dontAllowShortReads ()
void allowShortWrites ()
void dontAllowShortWrites ()
void useListener (listener *lstnr)
void dontUseListener ()
listenergetListener ()
void useListenerInsideReads ()
void dontUseListenerInsideReads ()
void useListenerInsideWrites ()
void dontUseListenerInsideWrites ()
virtual bool passFileDescriptor (int32_t fd) const
virtual bool receiveFileDescriptor (int32_t *fd) const
void translateByteOrder ()
void dontTranslateByteOrder ()
int32_t fCntl (int32_t command, long arg) const
int32_t ioCtl (int32_t command, void *arg) const
bool useNaglesAlgorithm ()
bool dontUseNaglesAlgorithm ()
bool setTcpWriteBufferSize (int32_t size)
bool getTcpWriteBufferSize (int32_t *size)
bool setTcpReadBufferSize (int32_t size)
bool getTcpReadBufferSize (int32_t *size)
const char * getType () const
char * getPeerAddress () const
bool setWriteBufferSize (ssize_t size) const
bool flushWriteBuffer (long sec, long usec) const
bool setReadBufferSize (ssize_t size) const
bool closeOnExec ()
bool dontCloseOnExec ()
bool getCloseOnExec ()

Additional Inherited Members

- Private Member Functions inherited from modemutil
void initialize (const char *device, const char *baud)
const char * _devicename ()
const char * _baud ()
bool configureSerialPort (int32_t fd, const char *baud)

Detailed Description

The modemserver class allows you to write programs taht can talk to other programs across a direct serial modem connection.

The modemserver class provides methods for setting up a modem and accepting client connections. Its ultimate parent class, filedescriptor, provides methods for reading and writing data.

If you need to listen on more than one modem at a time or a combination of modems and other file descriptors (such as sockets), then you should use the modemserver class in conjunction with the listener class.


Constructor & Destructor Documentation

modemserver::modemserver ( )

Creates an instance of the modemserver class.

modemserver::modemserver ( const modemserver m)

Creates an instance of the modemserver class that is a copy of "m".

virtual modemserver::~modemserver ( )
virtual

Deletes this instance of the modemserver class.


Member Function Documentation

filedescriptor* modemserver::accept ( )
virtual

Waits for a client connection. When a client connects, it runs "acceptscript" which was set in the call to initialize().

Returns true on success and false on failure.

Implements server.

bool modemserver::bind ( )
virtual

Does nothing in the default implementation but a child class might implement it to do something. This version always returns true.

Implements server.

bool modemserver::close ( )
virtual

Runs "disconnectscript" which was set in the call to initialize() and closes the device.

Returns true on success and false on failure.

Reimplemented from filedescriptor.

void modemserver::initialize ( const char *  device,
const char *  baud,
const char *  listenscript,
const char *  acceptscript,
const char *  disconnectscript 
)

Initializes the class to opens "device", set the baud rate to "baud", and run "listenscript" when listen() is called. When a client connects, "acceptscript" will be run. When the client disconnects, "disconnecctscript" will be run.

Returns true on success and false on failure.

bool modemserver::listen ( const char *  device,
const char *  baud,
const char *  listenscript,
const char *  acceptscript,
const char *  disconnectscript 
)

Convenience method that calls initialize(), bind(), and listen(). If you need to do anything special between those discrete steps, then you should use the methods individually.

Opens "device", sets the baud rate to "baud", then runs "listenscript". When a client connects, "acceptscript" will be run. When the client disconnects, "disconnecctscript" will be run.

Returns true on success and false on failure.

bool modemserver::listen ( int32_t  backlog)
virtual

Opens the device set in the call to initalize(), sets the baud rate and runs "listenscript".

Returns true on success and false on failure.

Implements server.

modemserver& modemserver::operator= ( const modemserver m)

Makes this instance of the modemserver class identical to "m".