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

LSD::ServiceDirectory Class Reference

This class represents a service directory. More...

#include <servicedirectory.hh>

List of all members.

Public Member Functions

Static Public Attributes

Options you can pass to the constructor

Detailed Description

This class represents a service directory.

Service directories can query and advertise services which are registered locally, or remotely, via UDP broadcast or point-to-point TCP messages. A service is identified by human readable title and description, a list of type strings, and a URL.

Todo:
add optional relaying of all local traffic to remote tcp relays.

Definition at line 62 of file servicedirectory.hh.


Constructor & Destructor Documentation

ServiceDirectory::ServiceDirectory short  options  ) 
 

Constructor.

Parameters:
options Mask of options: see above. Options may be combined with |. The defaults may be negated with ^ (e.g. ^ServiceDirectory::LISTEN_BCAST)

Definition at line 156 of file servicedirectory.cc.

ServiceDirectory::ServiceDirectory  ) 
 

Constructor.

Uses default options * LISTEN_BCAST|RELAY_TCP_TO_BCAST|RELAY_BCAST_TO_TCP

Definition at line 172 of file servicedirectory.cc.

ServiceDirectory::~ServiceDirectory  )  [virtual]
 

Destructor: all open sockets are shut down.

Definition at line 212 of file servicedirectory.cc.


Member Function Documentation

void ServiceDirectory::addRelay char *  hostname,
int  port = 4229
[virtual]
 

Also relay queries via TCP to service directory running at the given host and port.

Use with listenTCP() to span networks.

Definition at line 570 of file servicedirectory.cc.

void ServiceDirectory::addService Service s  )  [virtual]
 

Add service to directory.

Definition at line 504 of file servicedirectory.cc.

void ServiceDirectory::endQuery int  q  )  [virtual]
 

End query with identifier q.

Definition at line 286 of file servicedirectory.cc.

deque< int > ServiceDirectory::getIncomingTCPFds  )  [virtual]
 

Get incoming tcp file descriptors.

Definition at line 615 of file servicedirectory.cc.

deque< int > ServiceDirectory::getRelayFds  )  [virtual]
 

Get outgoing tcp remote relay file descriptors.

Definition at line 604 of file servicedirectory.cc.

virtual int LSD::ServiceDirectory::getTCPfd  )  [inline, virtual]
 

Get TCP socket file descriptor (listening).

Definition at line 160 of file servicedirectory.hh.

virtual int LSD::ServiceDirectory::getUDPfd  )  [inline, virtual]
 

Get UDP socket file descriptor.

Definition at line 157 of file servicedirectory.hh.

void ServiceDirectory::handleIncoming float  timeout = -1  )  [virtual]
 

Check UDP and TCP sockets (via a call to select), and handle incoming queries and advertisements from remote directories.

This method must be called periodically in order to maintain an active directory.

Parameters:
timeout Timeout on select call, in seconds. Omit the parameter or use -1 to block until a socket has data. Use 0 to return immediately.

Definition at line 291 of file servicedirectory.cc.

void ServiceDirectory::listenTCP int  port = 4229  )  [virtual]
 

Listen on a TCP port for messages, which will be responded to in handleIncoming().

Parameters:
port Port to listen on. If -1, then any open TCP socket will be closed.
Call relayIncomingTCP() to cause handleIncoming() to also relay messages to local broadcast. Use with addRelay() to span networks with a symetrical set-up on the other end. This feature can also be used as a simple way to enable multiple services to share a host's service directory.

If you passed ServiceDirectory::LISTEN_TCP to the constructor, then calling this is unnecessary.

You can only listen on one TCP port.

Definition at line 550 of file servicedirectory.cc.

Referenced by ServiceDirectory().

void ServiceDirectory::listenUDP int  port = 4230  )  [virtual]
 

Listen on a UDP port for messages, which will be responded to in handleIncoming().

Parameters:
port Port to listen on. If -1, then any open TCP socket will be closed. You want to use the default, 4230, unless the other service directories on the socal net that you want to talk to are using some other port for recieving udp broadcast messages.
If you pass ServiceDirectory::LISTEN_BCAST to the constructor, (the default argument) then calling this is unnecessary.

You can only listen on one UDP port.

Definition at line 185 of file servicedirectory.cc.

Referenced by ServiceDirectory().

int ServiceDirectory::query const std::string &  typepattern,
const std::string &  titlepattern,
const std::string &  descpattern,
const std::string &  urlpattern,
ServiceAdvertismentListener cb
[virtual]
 

Start a query on both this directory and remote directories for services which match the given patterns.

The listener is notified when a matching service is found. If any remote relays have been added, the query will also be sent to each one (see addRelay())

Returns:
a unique identifier for this query

Definition at line 230 of file servicedirectory.cc.

virtual void LSD::ServiceDirectory::relayIncomingTCP bool  v = true  )  [inline, virtual]
 

Cause handleIncoming() to also relay incomming TCP messages broadcast to local network (or stop relaying if argument is false).

(Only useful if listenTCP() has been called or ServiceDirectory::LISTEN_TCP was passed to the constructor. Calling this is the same as passing ServiceDirectory::RELAY_TCP_TO_BCAST|ServiceDirectory::LISTEN_TCP to the constructor.)

Definition at line 210 of file servicedirectory.hh.

void ServiceDirectory::removeRelay char *  hostname,
int  port = 4229
[virtual]
 

Don't relay queries to the specified directory.

Definition at line 594 of file servicedirectory.cc.

Referenced by addService(), handleIncoming(), and query().

void ServiceDirectory::removeService Service s  )  [virtual]
 

Remove service from directory.

Definition at line 545 of file servicedirectory.cc.


Member Data Documentation

short ServiceDirectory::LISTEN_BCAST = 0x1 [static]
 

Listen on local subnet UDP broadcast.

Definition at line 149 of file servicedirectory.cc.

Referenced by ServiceDirectory().

short ServiceDirectory::LISTEN_TCP = 0x2 [static]
 

Listen on TCP port 4229.

Definition at line 150 of file servicedirectory.cc.

Referenced by ServiceDirectory().

short ServiceDirectory::RELAY_BCAST_TO_TCP = 0x8 [static]
 

Relay from local broadcast to remote TCP relay points.

See also:
addRelay.

Definition at line 152 of file servicedirectory.cc.

Referenced by ServiceDirectory().

short ServiceDirectory::RELAY_TCP_TO_BCAST = 0x4 [static]
 

Relay from TCP ports to local broadcast.

Definition at line 151 of file servicedirectory.cc.

Referenced by ServiceDirectory().

short ServiceDirectory::RELAY_TCP_TO_REMOTE = 0x16 [static]
 

Relay from incoming TCP ports to remote relay points (see addRelay).

Definition at line 153 of file servicedirectory.cc.

Referenced by ServiceDirectory().


The documentation for this class was generated from the following files:
Generated on Tue Aug 12 03:56:02 2003 for Interreality Project - VOS by doxygen 1.3.2