Rudiments
Public Member Functions
unixclientsocket Class Reference

Inherits clientsocket, and unixsocketutil.

List of all members.

Public Member Functions

 unixclientsocket ()
 unixclientsocket (const unixclientsocket &u)
unixclientsocketoperator= (const unixclientsocket &u)
virtual ~unixclientsocket ()
int32_t connect (const char *filename, long timeoutsec, long timeoutusec, unsigned long retrywait, unsigned long retrycount)
void initialize (constnamevaluepairs *cd)
void initialize (const char *filename, long timeoutsec, long timeoutusec, unsigned long retrywait, unsigned long retrycount)
int32_t connect ()
- Public Member Functions inherited from clientsocket
 clientsocket ()
 clientsocket (const clientsocket &c)
clientsocketoperator= (const clientsocket &c)
virtual ~clientsocket ()
virtual bool supportsBlockingNonBlockingModes ()
virtual bool useNonBlockingMode () const
virtual bool useBlockingMode () const
- Public Member Functions inherited from client
 client ()
 client (const client &c)
clientoperator= (const client &c)
virtual ~client ()
virtual const char * getVerboseConnectError ()
virtual void setVerboseConnectError (const char *error)
- Public Member Functions inherited from filedescriptor
 filedescriptor ()
 filedescriptor (const filedescriptor &f)
filedescriptoroperator= (const filedescriptor &f)
virtual ~filedescriptor ()
virtual bool close ()
int32_t getFileDescriptor () const
void setFileDescriptor (int32_t filedesc)
int32_t duplicate () const
bool duplicate (int32_t newfd) 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 unixsocketutil
 unixsocketutil ()
 unixsocketutil (const unixsocketutil &u)
unixsocketutiloperator= (const unixsocketutil &u)
virtual ~unixsocketutil ()
void initialize (const char *filename)

Detailed Description

The unixclientsocket class allows you to write programs that can talk to other programs on the same machine over TCP stream sockets.

Inet sockets (see the inetclientsocket class) can be used by clients and servers on the same machine as well, but Unix sockets generally perform better.

The unixclientsocket class provides methods for connecting to servers. Its ultimate parent class: filedescriptor provides methods for reading and writing data and closing connections.


Constructor & Destructor Documentation

unixclientsocket::unixclientsocket ( )

Creates an instance of the unixclientsocket class.

unixclientsocket::unixclientsocket ( const unixclientsocket u)

Creates an instance of the unixclientsocket class. that is a copy of "u".

virtual unixclientsocket::~unixclientsocket ( )
virtual

Deletes this instance of unixclientsocket.


Member Function Documentation

int32_t unixclientsocket::connect ( )
virtual

Attempts to connect to the "filename" set earlier. If the connection fails, it will retry "retrycount" times, waiting "retrywait" seconds between tries.

Setting "retrycount" to 0 will cause it to try to connect indefinitely. Setting "retrywait" to 0 will cause it to try to connect over and over as fast as possible (not recommended).

Each attempt to connect will wait "timeoutsec" seconds and "timeoutusec" microseconds for the connect to succeed. Specifying -1 for either parameter will cause the attempt to wait until the underlying protocol times out which may be up to 2 minutes.

Returns RESULT_SUCCESS on success and RESULT_ERROR on failure.

Implements client.

void unixclientsocket::initialize ( constnamevaluepairs cd)
virtual

Queries namevaluepairs "cd" for "filename", "timeoutsec", "timeoutusec", "retrywait" and "retrycount". Initializes the class to use the result when connect() is called.

Implements client.

void unixclientsocket::initialize ( const char *  filename,
long  timeoutsec,
long  timeoutusec,
unsigned long  retrywait,
unsigned long  retrycount 
)

Initializes the class to use "filename", "timeoutsec", "timeoutusec", "retrywait" and "retrycount" when connect() is called.

unixclientsocket& unixclientsocket::operator= ( const unixclientsocket u)

Makes this instance of the unixclientsocket class identical to "u".