nidas  v1.2-1520
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::core::McSocket::MyMcSocket Class Reference

#include <McSocket.h>

Inheritance diagram for nidas::core::McSocket::MyMcSocket:
Inheritance graph
[legend]

Public Member Functions

 MyMcSocket (nidas::core::McSocket *s)
 
void connected (nidas::util::Socket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
 Virtual method that is called when a socket connection is established. More...
 
void setInterface (Inet4NetworkInterface iaddr)
 Set a specific interface for the multicasts. More...
 
Inet4NetworkInterface getInterface () const
 
std::list< Inet4NetworkInterface > getInterfaces () const throw (IOException)
 Return all network interfaces on this system. More...
 
const Inet4SocketAddress & getInet4McastSocketAddress () const
 Get the multicast address for listening to requests. More...
 
void setInet4McastSocketAddress (const Inet4SocketAddress &val)
 Set the multicast address for listening to requests. More...
 
void setRequestType (int val)
 Set the request type value. More...
 
int getRequestType () const
 Get the request type number. More...
 
void listen () throw (IOException)
 Register with a McSocketListener to listen on the multicast address. More...
 
nidas::util::Socketaccept (Inet4PacketInfoX &) throw (IOException)
 Like ServerSocket::accept(), this method will return a connected socket. More...
 
void request () throw (IOException)
 Start issuing requests for a connection by multicasting McSocketDatagrams. More...
 
nidas::util::Socketconnect (Inet4PacketInfoX &) throw (IOException)
 Do a request(), and then wait until a TCP connection is established, or a UDP datagram is received back. More...
 
virtual void close () throw (IOException)
 Unregister this McSocket from the multicasting and listening threads. More...
 

Private Member Functions

 MyMcSocket (const MyMcSocket &)
 
MyMcSocketoperator= (const MyMcSocket &)
 

Private Attributes

nidas::core::McSocket_outer
 

Constructor & Destructor Documentation

nidas::core::McSocket::MyMcSocket::MyMcSocket ( nidas::core::McSocket s)
inline
nidas::core::McSocket::MyMcSocket::MyMcSocket ( const MyMcSocket )
private

Member Function Documentation

Like ServerSocket::accept(), this method will return a connected socket.

As with listen(), it registers with a McSocketListener to listen on the multicast address, then waits until a request is received with a matching request type and socket type. accept() will return with a pointer to a connected TCP Socket for a McSocket<Socket>, or to a DatagramSocket for a McSocket<DatagramSocket>, with a default destination address of the requesting host and port. The caller owns the pointer to the socket and is responsible for closing and deleting it when done.

virtual void nidas::util::McSocket< nidas::util::Socket >::close ( )
throw (IOException
)
virtualinherited

Unregister this McSocket from the multicasting and listening threads.

Do a request(), and then wait until a TCP connection is established, or a UDP datagram is received back.

Returns the pointer to the connected TCP Socket or the DatagramSocket. McSocket then owns the pointer to the socket and is responsible for closing and deleting it when done.

void nidas::core::McSocket::MyMcSocket::connected ( nidas::util::Socket ,
const nidas::util::Inet4PacketInfoX  
)
inlinevirtual

Virtual method that is called when a socket connection is established.

This must be implemented in derived classes if the user wants to implement an asynchronous, two-step connection using listen() instead of accept() for incoming requests or request() instead of connect() for outgoing requests.

Parameters
sockThe socket which is ready for I/O. McSocket then owns the pointer to the socket and is responsible for closing and deleting it when done.

Reimplemented from nidas::util::McSocket< nidas::util::Socket >.

const Inet4SocketAddress& nidas::util::McSocket< nidas::util::Socket >::getInet4McastSocketAddress ( ) const
inlineinherited

Get the multicast address for listening to requests.

References nidas::util::McSocket< SocketT >::_mcastAddr.

Inet4NetworkInterface nidas::util::McSocket< nidas::util::Socket >::getInterface ( ) const
inlineinherited
std::list<Inet4NetworkInterface> nidas::util::McSocket< nidas::util::Socket >::getInterfaces ( ) const
throw (IOException
)
inherited

Return all network interfaces on this system.

int nidas::util::McSocket< nidas::util::Socket >::getRequestType ( ) const
inlineinherited

Get the request type number.

References nidas::util::McSocket< SocketT >::_requestType.

void nidas::util::McSocket< nidas::util::Socket >::listen ( )
throw (IOException
)
inherited

Register with a McSocketListener to listen on the multicast address.

When a request is received on the socket port, with a matching request type and socket type, McSocketListener will either do a Socket::connect() to establish a TCP connection back to the requesting host and port if the socket type is SOCK_STREAM, or if the socket type is SOCK_DGRAM, will create a DatagramSocket with a default destination address of the requesting host and port. Once this has been done, McSocketListener will call the offer() method of this McSocket. offer() then calls the virtual connected() method, passing a pointer to the connected socket. Use either listen() or accept() to wait for a connection.

MyMcSocket& nidas::core::McSocket::MyMcSocket::operator= ( const MyMcSocket )
private
void nidas::util::McSocket< nidas::util::Socket >::request ( )
throw (IOException
)
inherited

Start issuing requests for a connection by multicasting McSocketDatagrams.

When a response is received, either in the form of a TCP socket connection in the case of a socket type of SOCK_STREAM, or a datagram is received in the case of a socket type of SOCK_DGRAM, then the connected() method is called.

void nidas::util::McSocket< nidas::util::Socket >::setInet4McastSocketAddress ( const Inet4SocketAddress val)
inlineinherited

Set the multicast address for listening to requests.

Parameters
valMulticast address to listen for McSocketDatagrams.

References nidas::util::McSocket< SocketT >::_mcastAddr.

void nidas::util::McSocket< nidas::util::Socket >::setInterface ( Inet4NetworkInterface  iaddr)
inlineinherited

Set a specific interface for the multicasts.

If a request() or connect() is done, then requests will be sent on this interface. If an listen() or accept() is done, then an MulticastSocket::joinInterface() will be done on this interface to listen for incoming datagrams. If the interface is not set, or is left at the default of INADDR_ANY, then McSocket will send on or join all available interfaces capable of multicast, including the loopback interface.

References nidas::util::McSocket< SocketT >::_iface.

void nidas::util::McSocket< nidas::util::Socket >::setRequestType ( int  val)
inlineinherited

Set the request type value.

This can be any number, agreed upon by the McSocket sending requests and the McSocket listening for requests.

Parameters
valRequest number

References nidas::util::McSocket< SocketT >::_requestType.

Referenced by nidas::core::XMLConfigInput::XMLConfigInput().

Member Data Documentation

nidas::core::McSocket* nidas::core::McSocket::MyMcSocket::_outer
private

The documentation for this class was generated from the following file: