[my project]
Package Name: Network
class CAuthenticator
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/Authenticator.h |
Given an account name and password, produces the corresponding authority
record for a given user.
Member Index
Class Methods
-
virtual CAuthorityRecord *Get( char *inAccount, char *inPassword, bool inNewRecord, char *outErrorBuf, int inErrBufSize );
-
Get an existing authority record.
- Parameters
-
|
inAccount | Login name of entity
|
inPassword | Entity's password
|
inNewRecord | True if entity is attempting to establish a new account.
|
outErrorBuf | description of error if any.
|
inErrBufSize | Size of error buffer |
|
class CAuthorityRecord
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/AuthorityRecord.h |
---|
Base classes: |
CRefCountObject |
A record of the authority possessed by a particular user.
Member Index
Class Methods
-
virtual char *AccountName();
-
Returns the name of this account.
-
virtual bool CanConnect();
-
Returns true if this entity is allowed to connect.
class CNetworkConnection
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/Connection.h |
---|
Base classes: |
CAbstractEvent |
Subclasses: |
CPipeConnection |
Base class for all connections managed by the Network
Manager. There are various pure virtual functions which are
called when the select() bits in the network manager are
twigged. Connections can function as both client or server,
but there are some differences in operation. Connections can
be constructed directly, or in response to some more abstract
need (such as the creation of a virtual pipe -- see
CPipeConnection).
Connections make extensive use of CRefCountObject reference,
so to avoid referential loops (i.e. garbage cycles) we specify
the "flow direction" of references, which in the case of
Connections is always upward, i.e. towards the manager.
CNetworkConnection --> CNetworkManager
Member Index
Class Methods
-
CNetworkConnection( CNetworkManager *inManager, char *inHostName, short inPort );
-
Constructor for "Client-side" connections. We know the address
of the machine we want to connect to, but we don't have a socket
yet.
REM: Should we allow a contstructor that takes a host name instead?
-
CNetworkConnection( CNetworkManager *inManager, CSockAddr *inAddr, int inSocket );
-
Constructor for "Server-side" connections, used in responding to
the "accept" call. In this case, the socket is already
known.
-
void CloseLocal();
-
Shutdown the connection on this end. This will cause the
other end to start shutting down as well.
-
virtual void Disconnect( char *inMessage );
-
Shut down the connection...
-
TConnectionState GetStatus();
-
Return the status of this connection.
-
virtual void OnConnectionEstablished();
-
Called by connection thread when call to Connect() returns.
Only relevant for clients.
-
void OnError( int inError );
-
Called when an error is detected.
-
virtual void OnRemoteClose();
-
Called when we get an EOF on the stream socket. Default
action is to call Disconnect( NULL );
-
int RecvDatagramData( void *inBuf, int inMaxLength );
-
Raw routine to receive datagram data. No interpretation of contents
is assumed. Returns number of bytes recieved, or -1 if failed. Should
be called by subclass's RecvNextDatagramPacket() function.
-
virtual void RecvNextDatagramPacket();
-
Called when we believe that there's a datagram waiting to be received.
Called by manager when there's data in the datagram input buffer.
-
virtual void RecvNextReliablePacket();
-
Called when we believe there's reliable data waiting to be recieved.
Called by manager when there's data in the reliable input buffer.
-
int RecvReliableData( void *inBuf, int inMaxLength );
-
Raw routine to receive reliable data. No interpretation of contents
is assumed. Returns number of bytes recieved, or -1 if failed. Should
be called by subclass's RecvNextReliablePacket() function.
-
int SendDatagramData( void *inBuf, int inLength );
-
Low-level routine to send datagram. No interpretation of contents
is assumed. Returns the number of bytes sent. Should
be called by subclass's SendNextDatagramPacket() function.
-
virtual bool SendNextDatagramPacket();
-
Retrieve the next reliable packet waiting to be sent and send it.
Called by manager when there's space in the datagram output buffer.
-
virtual bool SendNextReliablePacket();
-
Retrieve the next datagram waiting to be sent and send it.
Called by manager when there's space in the reliable output buffer.
-
int SendReliableData( void *inBuf, int inLength );
-
Raw routine to send reliable data. No interpretation of contents.
is assumed. Returns false if packet could not be sent. Should
be called by subclass's SendNextReliablePacket() function.
-
void SetDatagramSocket( int inStreamSocket );
-
Attach a socket to the connection.
-
~CNetworkConnection();
-
Destructor.
class CNetworkListener
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/Listener.h |
---|
Base classes: |
CAbstractEvent |
Subclasses: |
CPipeListener |
A listener listens to a particular port, accepts connections, and
creates connection objects to go with each accepted connection.
Subclasses of this can also create virtual connections, i.e. pipes,
within the main connection.
Member Index
Class Methods
-
CNetworkListener( CNetworkManager *inManager, int port );
-
Constructor
-
virtual void OnAcceptConnection( int newSocket, CSockAddr *inAddr );
-
Virtual function which is called whenever a new connection
is accepted.
-
void OnExecute();
-
Called when we want to check for any connection requests.
-
bool Valid();
-
Returns true if initialization succeeded.
-
virtual ~CNetworkListener();
-
Destructor
class CNetworkManager
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/Manager.h |
---|
Base classes: |
CAbstractEvent |
Manages all connections and listeners. Notifies them when there
is data available on their sockets.
Member Index
Class Methods
-
CAuthenticator *Authenticator();
-
Retrieve the authenticator for this manager.
-
CNetworkManager( CEventDispatcher &inDispatcher, CAuthenticator *inAuthenticator = NULL );
-
Close a connection to a remote machine. Constructor.
- Parameters
-
|
inDispatcher | Address of the event dispatcher.
|
inAuthenticator | -- address of class which will
facilitate authentication of incombing connections.
If it is NULL, it means that we don't want to
listen for incoming connections (default). |
|
-
bool CanRead( int inSock );
-
Atomically creates a connection if one does not already exist,
otherwise returns the existing connection. Increases the reference
count on the connection as a side effect.
Returns true if there is unread data for this socket.
-
bool CanWrite( int inSock );
-
Returns true if the socket could potentially write at this time.
-
void ClearIntentToWrite( int inSock );
-
Clears the intent-to-write bit.
-
void Lock();
-
Lock the mutex. Careful using this function.
-
void SetIntentToWrite( int inSock );
-
Set the bit indicating that we have data we would like to write on
this socket, but we can't because the buffer is full.
-
void Unlock();
-
Unlock the mutex. Careful using this function.
-
~CNetworkManager();
-
Destructor.
class CNetworkPipe
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/Pipe.h |
---|
Base classes: |
CRefCountObject |
Represents a virtual connection within a physical connection. There can
be up to 128 pipes within a single connection. Pipes so that individual
entities on the client (such as views, property editors, etc.) can
talk to individual entities on the server (i.e. services).
Member Index
Class Methods
-
int AddPacketSource( CPacketSource *inPacketSource, TDeliveryType inDelivery, uint8 inPriority );
-
Add a packet source to the packet list of this pipe's connection.
A packet source is used by the network code to generate
the data for a packet on demaned (this insures that packets
which are in the queue are sent with the latest state
information).
-
CNetworkPipe( CNetworkManager *inManager, char *inHost, short inPort, char *inAccountName, char *inAccountPass );
-
Constructor for "connect" style connections.
- Parameters
-
|
inManager | The address of the network dispatcher.
|
inAddr | The machine address to connect to.
|
inDefaultPipe | Indicates we want to establish a connection
as the "default" pipe, the one that gets called when
no other appropriate pipe can be found.
|
inDatagramsNeeded | Indicates datagram support is desired.
Connections always open a TCP stream; If this flag
is true, a UDP connection will be set up as well. |
|
-
CNetworkPipe( CPipeConnection *inConnection, uint8 inPipe );
-
Constructor for "accept" style connections.
-
bool Disconnect();
-
Called to disconnect this pipe -- releases the connection
-
void EnableDatagrams( bool inEnable = true );
-
Enable datagrams for this pipe. Initially disabled.
Only relevant for client pipes.
-
virtual void OnConnect();
-
Called when the connection is established.
-
virtual void OnDisconnect();
-
Called when the connection is shut down.
-
virtual void OnError( int inError );
-
Called when an error is detected for this pipe.
-
virtual void OnPacketReceived( uint8 *inBuffer, int32 inLength, bool inDatagram );
-
Called when a TCP/IP message is recieved.
-
TConnectionState Status();
-
Returns the status of this pipe
-
~CNetworkPipe();
-
Destructor -- removes pipe from connection if not already closed.
class CPacketSource
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/PacketSource.h |
---|
Base classes: |
RingNode, CRefCountObject |
This class represents the "intent" to send a packet. It need not
contain the actual packet data, although it can do so. Instead,
the packet data can be generated "on demand" just before the
packet is actually sent.
The reason for this class is that the networking code is implemented
using a "pull" architecture, which means that the connection object
requests the next piece of data to be sent whenever the amount
of data in the output buffer reaches the low water mark. The connection
object maintains a queue of packet sources, which are expected to
provide packet data on demand. The network connection is responsible for
prioritizing packet sources. When the network connection is ready to
send a packet, it removed the packet source from the head of the queue
and calls it's OnExecute function, which is expected to fill in the
supplied buffer with packet data.
Packets sources can re-queue themselves during their OnExecute functions if
it is desired to send a series of packets from the same source, for example
when doing a bulk download or sending a stream of motion packets.
One advantage of this architecture is that time-critical data will
not get stale waiting in the output buffer; Instead, the state of the
real-time variables can be sampled at the last possible moment before
the packet is actually sent.
Member Index
Class Methods
-
int Cancel();
-
Indicates that we don't want to send this packet.
-
virtual int OnExecute( uint8 *buffer, int32 size );
-
This routine is called by the network code when it believes
that a write operation can be performed without blocking.
The PacketSource object should create the packet to be output.
- Parameters
-
|
buffer | Contains a pointer to a buffer supplied by
the networking code.
|
size | A pointer to the size of buffer. |
|
-
int ReQueue( TDeliveryType newDelivery, int newPriority );
-
Indicates we want to send another packet, with perhaps a
new priority.
class CPipeConnection
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/PipeConnection.h |
---|
Base classes: |
CNetworkConnection |
A connection which supports up to 127 "pipes" or virtual
connections within a single socket connection. These pipes
can support both reliable packets and datagrams.
On the server side, each attempt to create a pipe will query
the network manager for a "virtual server" object to respond
to the pipe.
Reference counting: CPipeConnection keeps a reference on
packet sources. CNetworkPipe keeps a reference count on
CPipeConnection.
CPipeConnection --> CPacketSource
CNetworkPipe --> CPipeConnection
Member Index
Class Methods
-
int AddPacketSource( CPacketSource *inPacketSource, TDeliveryType inDelivery, uint8 inPriority );
-
Add a packet source to the packet list of this connection,
in order by priority. If the packet source is already
in another connection's queue, the function returns ???
A packet source is used by the network
code to generate the data for a packet on demaned (this
insures that packets which are in the queue are sent with
the latest state information). This function increments
the reference count of the packet source if the source
is not another list already. Returns 0 if it succeeded,
else a standard errno variable if it failed.
-
CPipeConnection( CNetworkManager *inManager, char *inHostName, short inPort, char *inAccountName, char *inAccountPass );
-
Constructor for "Client-side" connections. We know the address
of the machine we want to connect to, but we don't have a socket
yet.
-
CPipeConnection( CNetworkManager *inManager, CSockAddr *inAddr, int inSocket );
-
Constructor for "Server-side" connections, used in responding to
the "accept" call. In this case, the socket is already
known.
-
int CancelPacketSource( CPacketSource *inPacketSource );
-
Remove impending packet from queue, but only if it was
on this connection's queue. If so, the reference count of the
packet source is decremented. Returns 0 on success, EINVAL
if the packet was not queued on this connection.
-
void Disconnect( char *inMessage );
-
Shut down the connection...
-
TConnectionState GetStatus();
-
Return the status of this connection.
-
void OnError( int inError );
-
Called when an error is detected.
-
~CPipeConnection();
-
Destructor.
class CPipeListener
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/PipeListener.h |
---|
Base classes: |
CNetworkListener |
A CPipeListener listens to a particular port, and accepts connections
made to it. It then creates a CPipeConnection object to represent
the connection.
Member Index
Class Methods
-
CPipeListener( CNetworkManager *inManager, int port );
-
Constructor.
- Parameters
-
|
inManager | The address of the network manager object.
|
port | The port to listen to. |
|
-
virtual CNetworkPipe *MakeServerPipe( CNetworkConnection *inConnection, char *inServerUID );
-
This hook function is called on the server when the client wishes
to create a new virtual connection within the CPipeConnection.
It should create both a pipe and an instance of a virtual server
to talk to.
-
void OnAcceptConnection( int newSocket, CSockAddr *addr );
-
Called by base class whenever it accepts a new connection.
Responds by creating a CPipeConnections object.
-
~CPipeListener();
-
Destructor.
struct CSockAddr
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/SockAddr.h |
CSockAddr is a lightweight abstraction of sockaddr_in. It's main
intent is to be able to transparently support IPV6 in future
revisions.
Member Index
Class Methods
-
CSockAddr();
-
Constructor, initializes family to an invalid value.
-
CSockAddr( CSockAddr &inAddr );
-
Copy constructor
-
int Family();
-
Return the family of this address.
-
bool Format( char *outAddrName, int inMaxLength );
-
Format this address into a presentation string.
- Parameters
-
|
outAddrName | A buffer to write the ascii formatted
network address to.
|
inMaxLength | The length of buffer. |
|
-
bool Init( int inFamily, void *inAddr, int inPort );
-
Initialize this socket address.
- Parameters
-
|
inFamily | The address family.
|
inAddr | A pointer to the network address, in network
byte order. For AF_INET, inAddr must point to a 32-bit
integer.
|
inPort | A 16-bit port number in network byte order. |
|
-
bool Init( sockaddr *inAddr );
-
Initialize from a sockaddr structure.
-
bool IsEqualTo( const CSockAddr *inAddr );
-
Compare with another CSockAddr
-
bool IsEqualTo( const sockaddr *inAddr );
-
Compare with a sockaddr structure
-
int MaxSize();
-
Return the maximum size sockaddr that will fit.
-
sockaddr *Pointer();
-
Return a pointer to the completed address structure. Note
that it is allowed to write to this pointer, i.e. it's not
a const.
-
int Port();
-
Return the port in network byte order.
-
int Size();
-
Return the size of this address in bytes.
class UHostDB
|
Author: | Talin
|
---|
Source: | /home/talin/Elfland/Network/UHostDB.h |
A Utility class which encapsulates a number of host lookup functions,
and insures that they are thread-safe, and also that they will work
with IPV6.
Member Index
Class Methods
-
static bool LookupAddress( char *inName, CSockAddr *outAddr, int defaultPort );
-
Given a host name (or ascii IP address) return the numeric
IP address in network order.
-
static char *LookupName( CSockAddr *inAddr );
-
Given an IP address (in network order), allocate a string
containing the host name.
© 1998 [my name]
Generated by ScanDoc
Last Updated: Thu Jul 30 23:14:22 1998