nidas
v1.2-1520
|
#include <McSocketUDP.h>
Public Member Functions | |
MyMcSocket (nidas::core::McSocketUDP *s) | |
void | connected (nidas::util::DatagramSocket *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::DatagramSocket * | accept (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::DatagramSocket * | connect (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 &) | |
No copy, assignment. More... | |
MyMcSocket | operator= (const MyMcSocket &) |
Private Attributes | |
nidas::core::McSocketUDP * | _outer |
|
inline |
|
private |
No copy, assignment.
|
inherited |
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.
|
virtualinherited |
Unregister this McSocket from the multicasting and listening threads.
|
inherited |
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.
|
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.
sock | The 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::DatagramSocket >.
|
inlineinherited |
Get the multicast address for listening to requests.
|
inlineinherited |
|
inherited |
Return all network interfaces on this system.
|
inlineinherited |
Get the request type number.
|
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.
|
private |
|
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.
|
inlineinherited |
Set the multicast address for listening to requests.
val | Multicast address to listen for McSocketDatagrams. |
|
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.
|
inlineinherited |
Set the request type value.
This can be any number, agreed upon by the McSocket sending requests and the McSocket listening for requests.
val | Request number |
|
private |