Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fawkes::MulticastDatagramSocket Class Reference

Multicast datagram socket. More...

#include <netcomm/socket/datagram.h>

Inheritance diagram for fawkes::MulticastDatagramSocket:

Public Member Functions

 MulticastDatagramSocket (const char *multicast_addr_s, unsigned short port, float timeout=0.f)
 Constructor.
 MulticastDatagramSocket (MulticastDatagramSocket &s)
 Copy constructor.
virtual ~MulticastDatagramSocket ()
 Destructor.
virtual Socketclone ()
 Clone socket.
virtual void bind ()
 Bind socket.
virtual void send (void *buf, unsigned int buf_len)
 Send data.
void set_loop (bool loop)
 Set loopback of sent packets.
void set_ttl (int ttl)
 Set multicast time-to-live (TTL)
- Public Member Functions inherited from fawkes::Socket
 Socket (int domain, int type, int protocol, float timeout=0.f)
 Constructor similar to syscall.
 Socket (Socket &socket)
 Copy constructor.
virtual ~Socket ()
 Destructor.
virtual void connect (const char *hostname, const unsigned short int port)
 Connect socket.
virtual void connect (struct sockaddr *addr_port, unsigned int struct_size)
 Connect socket.
virtual void bind (const unsigned short int port)
 Bind socket.
virtual void bind (const unsigned short int port, const char *hostname)
 Bind socket to a specific address.
virtual void listen (int backlog=1)
 Listen on socket.
virtual Socketaccept ()
 Accept connection.
virtual void close ()
 Close socket.
virtual bool available ()
 Check if data is available.
virtual size_t read (void *buf, size_t count, bool read_all=true)
 Read from socket.
virtual void write (const void *buf, size_t count)
 Write to the socket.
virtual void send (void *buf, size_t buf_len)
 Write to the socket.
virtual void send (void *buf, size_t buf_len, const struct sockaddr *to_addr, socklen_t addr_len)
 Send message.
virtual size_t recv (void *buf, size_t buf_len)
 Read from socket.
virtual size_t recv (void *buf, size_t buf_len, struct sockaddr *from_addr, socklen_t *addr_len)
 Receive data.
virtual short poll (int timeout=-1, short what=POLL_IN|POLL_HUP|POLL_PRI|POLL_RDHUP)
 Wait for some event on socket.
virtual bool listening ()
 Is socket listening for connections?
virtual unsigned int mtu ()
 Maximum Transfer Unit (MTU) of socket.
template<class SocketType >
SocketType * accept ()
 Accept connection.

Additional Inherited Members

- Static Public Attributes inherited from fawkes::Socket
static const short POLL_IN = POLLIN
 Data can be read.
static const short POLL_OUT = POLLOUT
 Writing will not block.
static const short POLL_PRI = POLLPRI
 There is urgent data to read (e.g., out-of-band data on TCP socket; pseudo-terminal master in packet mode has seen state change in slave).
static const short POLL_RDHUP = 0
 Stream socket peer closed connection, or shut down writing half of connection.
static const short POLL_ERR = POLLERR
 Error condition.
static const short POLL_HUP = POLLHUP
 Hang up.
static const short POLL_NVAL = POLLNVAL
 Invalid request.
- Protected Member Functions inherited from fawkes::Socket
 Socket ()
 Constructor.
- Protected Attributes inherited from fawkes::Socket
int sock_fd
 Socket file descriptor.
float timeout
 Timeout in seconds for various operations.
struct::sockaddr_in * client_addr
 Client address, set if connected.
unsigned int client_addr_len
 length in bytes of client address.

Detailed Description

Multicast datagram socket.

An multicast UDP socket on top of IP.

Author
Tim Niemueller

Definition at line 32 of file datagram_multicast.h.

Constructor & Destructor Documentation

fawkes::MulticastDatagramSocket::MulticastDatagramSocket ( const char *  multicast_addr_s,
unsigned short  port,
float  timeout = 0.f 
)

Constructor.

Parameters
multicast_addr_stextual representation of the multicast IP address to use for multicast communication. NOT a hostname!
portport
timeouttimeout, if 0 all operationsare blocking, otherwise it is tried for timeout seconds.

Definition at line 50 of file datagram_multicast.cpp.

References set_loop().

Referenced by clone().

fawkes::MulticastDatagramSocket::MulticastDatagramSocket ( MulticastDatagramSocket datagram_socket)

Copy constructor.

Parameters
datagram_socketsocket to copy.

Definition at line 80 of file datagram_multicast.cpp.

fawkes::MulticastDatagramSocket::~MulticastDatagramSocket ( )
virtual

Destructor.

Definition at line 71 of file datagram_multicast.cpp.

Member Function Documentation

void fawkes::MulticastDatagramSocket::bind ( )
virtual

Bind socket.

This will make the socket listen for incoming traffic. It will also add this host to the appropriate multicast group.

Definition at line 93 of file datagram_multicast.cpp.

References fawkes::Socket::sock_fd.

Referenced by fawkes::WorldInfoTransceiver::WorldInfoTransceiver().

Socket * fawkes::MulticastDatagramSocket::clone ( )
virtual

Clone socket.

Returns
a copied instance of MulticastDatagramSocket.

Implements fawkes::Socket.

Definition at line 122 of file datagram_multicast.cpp.

References MulticastDatagramSocket().

void fawkes::MulticastDatagramSocket::send ( void *  buf,
unsigned int  buf_len 
)
virtual

Send data.

This will send the given data to the multicast address specified in the constructor.

Parameters
bufbuffer to write
buf_lenlength of buffer, number of bytes to write to stream

Definition at line 135 of file datagram_multicast.cpp.

References fawkes::Exception::append().

void fawkes::MulticastDatagramSocket::set_loop ( bool  loop)

Set loopback of sent packets.

Parameters
looptrue to deliver sent packets to local sockets, false prevent delivering

Definition at line 150 of file datagram_multicast.cpp.

References fawkes::Socket::sock_fd.

Referenced by MulticastDatagramSocket(), and fawkes::WorldInfoTransceiver::set_loop().

void fawkes::MulticastDatagramSocket::set_ttl ( int  ttl)

Set multicast time-to-live (TTL)

Parameters
ttltime-to-live

Definition at line 163 of file datagram_multicast.cpp.

References fawkes::Socket::sock_fd.


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