Rudiments
Public Member Functions
unixserversocket Class Reference

Inherits serversocket, and unixsocketutil.

List of all members.

Public Member Functions

 unixserversocket ()
 unixserversocket (const unixserversocket &u)
unixserversocketoperator= (const unixserversocket &u)
virtual ~unixserversocket ()
bool listen (const char *filename, mode_t mask, int32_t backlog)
bool initialize (const char *filename, mode_t mask)
bool bind ()
bool listen (int32_t backlog)
filedescriptoraccept ()

Detailed Description

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

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

The unixserversocket class provides methods for setting up sockets and accepting client connections. Its ultimate parent class: transport, provides methods for reading and writing data and closing connections. An immediate parent class: unixsocket provides methods for passing file descriptors between connected instances of unixservertsocket's and unixclientsocket's.

If you need to listen on more than 1 socket at a time, you should use the unixserversocket class (and possibly the unixserversocket class) in conjunction with the listener class.


Constructor & Destructor Documentation

unixserversocket::unixserversocket ( )

Creates an instance of the unixserversocket class.

unixserversocket::unixserversocket ( const unixserversocket u)

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

virtual unixserversocket::~unixserversocket ( ) [virtual]

Deletes this instance of the unixserversocket class.


Member Function Documentation

filedescriptor* unixserversocket::accept ( ) [virtual]

Removes the client connection from the queue and associates a new socket with that connection. Communication with the client may be done over this new socket.

Returns an inetsocket on success and NULL on failure.

Implements server.

bool unixserversocket::bind ( ) [virtual]

Associates the socket with an address.

Returns true on success and false on failure.

Implements server.

bool unixserversocket::initialize ( const char *  filename,
mode_t  mask 
)

Creates the actual socket and initializes the class to use "filename" when bind() is called. The permissions on "filename" will be set using umask "mask".

Returns true on success and false on failure.

bool unixserversocket::listen ( int32_t  backlog) [virtual]

Waits until a client connects then places that connection in queue. Up to "backlog" connections may be queued before future conenctions are refused.

Returns true on success and false on failure.

Reimplemented from serversocket.

bool unixserversocket::listen ( const char *  filename,
mode_t  mask,
int32_t  backlog 
)

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

Listen on "filename" and allow "backlog" connections to pile up before refusing them. Set the permissions on "filename" using umask "mask".

Returns true on success and false on failure.

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

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