Fawkes API
Fawkes Development Version
|
Multicast datagram socket. More...
#include <netcomm/socket/datagram.h>
Public Member Functions | |
MulticastDatagramSocket (const char *multicast_addr_s, unsigned short port, float timeout=0.f) | |
Constructor. More... | |
MulticastDatagramSocket (MulticastDatagramSocket &s) | |
Copy constructor. More... | |
virtual | ~MulticastDatagramSocket () |
Destructor. More... | |
virtual Socket * | clone () |
Clone socket. More... | |
virtual void | bind () |
Bind socket. More... | |
virtual void | send (void *buf, unsigned int buf_len) |
Send data. More... | |
void | set_loop (bool loop) |
Set loopback of sent packets. More... | |
void | set_ttl (int ttl) |
Set multicast time-to-live (TTL) More... | |
![]() | |
Socket (int domain, int type, int protocol, float timeout=0.f) | |
Constructor similar to syscall. More... | |
Socket (Socket &socket) | |
Copy constructor. More... | |
virtual | ~Socket () |
Destructor. More... | |
virtual void | connect (const char *hostname, const unsigned short int port) |
Connect socket. More... | |
virtual void | connect (struct sockaddr *addr_port, unsigned int struct_size) |
Connect socket. More... | |
virtual void | bind (const unsigned short int port) |
Bind socket. More... | |
virtual void | bind (const unsigned short int port, const char *hostname) |
Bind socket to a specific address. More... | |
virtual void | listen (int backlog=1) |
Listen on socket. More... | |
virtual Socket * | accept () |
Accept connection. More... | |
virtual void | close () |
Close socket. More... | |
virtual bool | available () |
Check if data is available. More... | |
virtual size_t | read (void *buf, size_t count, bool read_all=true) |
Read from socket. More... | |
virtual void | write (const void *buf, size_t count) |
Write to the socket. More... | |
virtual void | send (void *buf, size_t buf_len) |
Write to the socket. More... | |
virtual void | send (void *buf, size_t buf_len, const struct sockaddr *to_addr, socklen_t addr_len) |
Send message. More... | |
virtual size_t | recv (void *buf, size_t buf_len) |
Read from socket. More... | |
virtual size_t | recv (void *buf, size_t buf_len, struct sockaddr *from_addr, socklen_t *addr_len) |
Receive data. More... | |
virtual short | poll (int timeout=-1, short what=POLL_IN|POLL_HUP|POLL_PRI|POLL_RDHUP) |
Wait for some event on socket. More... | |
virtual bool | listening () |
Is socket listening for connections? More... | |
virtual unsigned int | mtu () |
Maximum Transfer Unit (MTU) of socket. More... | |
template<class SocketType > | |
SocketType * | accept () |
Accept connection. More... | |
Additional Inherited Members | |
![]() | |
static const short | POLL_IN = POLLIN |
Data can be read. More... | |
static const short | POLL_OUT = POLLOUT |
Writing will not block. More... | |
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). More... | |
static const short | POLL_RDHUP = 0 |
Stream socket peer closed connection, or shut down writing half of connection. More... | |
static const short | POLL_ERR = POLLERR |
Error condition. More... | |
static const short | POLL_HUP = POLLHUP |
Hang up. More... | |
static const short | POLL_NVAL = POLLNVAL |
Invalid request. More... | |
![]() | |
Socket () | |
Constructor. More... | |
![]() | |
int | sock_fd |
Socket file descriptor. More... | |
float | timeout |
Timeout in seconds for various operations. More... | |
struct::sockaddr_in * | client_addr |
Client address, set if connected. More... | |
unsigned int | client_addr_len |
length in bytes of client address. More... | |
Multicast datagram socket.
An multicast UDP socket on top of IP.
Definition at line 32 of file datagram_multicast.h.
fawkes::MulticastDatagramSocket::MulticastDatagramSocket | ( | const char * | multicast_addr_s, |
unsigned short | port, | ||
float | timeout = 0.f |
||
) |
Constructor.
multicast_addr_s | textual representation of the multicast IP address to use for multicast communication. NOT a hostname! |
port | port |
timeout | timeout, 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.
datagram_socket | socket to copy. |
Definition at line 80 of file datagram_multicast.cpp.
|
virtual |
Destructor.
Definition at line 71 of file datagram_multicast.cpp.
|
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(), Msl2008RefBoxRepeater::~Msl2008RefBoxRepeater(), and Msl2010RefBoxProcessor::~Msl2010RefBoxProcessor().
|
virtual |
Clone socket.
Implements fawkes::Socket.
Definition at line 122 of file datagram_multicast.cpp.
References MulticastDatagramSocket().
|
virtual |
Send data.
This will send the given data to the multicast address specified in the constructor.
buf | buffer to write |
buf_len | length of buffer, number of bytes to write to stream |
Definition at line 135 of file datagram_multicast.cpp.
References fawkes::Exception::append(), and fawkes::Socket::send().
void fawkes::MulticastDatagramSocket::set_loop | ( | bool | loop | ) |
Set loopback of sent packets.
loop | true 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(), fawkes::WorldInfoTransceiver::set_loop(), Msl2008RefBoxRepeater::~Msl2008RefBoxRepeater(), and Msl2010RefBoxProcessor::~Msl2010RefBoxProcessor().
void fawkes::MulticastDatagramSocket::set_ttl | ( | int | ttl | ) |
Set multicast time-to-live (TTL)
ttl | time-to-live |
Definition at line 163 of file datagram_multicast.cpp.
References fawkes::Socket::sock_fd.