|
Fawkes API
Fawkes Development Version
|
Broadcast datagram socket. More...
#include <netcomm/socket/datagram.h>

Public Member Functions | |
| BroadcastDatagramSocket (const char *broadcast_addr_s, unsigned short port, float timeout=0.f) | |
| Constructor. More... | |
| BroadcastDatagramSocket (BroadcastDatagramSocket &s) | |
| Copy constructor. More... | |
| virtual | ~BroadcastDatagramSocket () |
| Destructor. More... | |
| BroadcastDatagramSocket & | operator= (BroadcastDatagramSocket &s) |
| Assignment operator. More... | |
| virtual Socket * | clone () |
| Clone socket. More... | |
| virtual void | bind () |
| Bind 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 | send (void *buf, size_t buf_len) |
| Send data. More... | |
| virtual void | send (void *buf, size_t buf_len, const struct sockaddr *to_addr, socklen_t addr_len) |
| Send message. More... | |
Public Member Functions inherited from fawkes::Socket | |
| Socket (AddrType addr_type, SocketType sock_type, float timeout=0.f) | |
| Constructor similar to syscall. More... | |
| Socket (Socket &socket) | |
| Copy constructor. More... | |
| virtual | ~Socket () |
| Destructor. More... | |
| Socket & | operator= (Socket &socket) |
| Copy constructor. More... | |
| virtual void | connect (const char *hostname, const unsigned short int port) |
| Connect socket. More... | |
| virtual void | connect (const struct ::sockaddr_storage &addr_port) |
| Connect socket. More... | |
| virtual void | connect (const struct sockaddr *addr_port, socklen_t struct_size) |
| Connect socket. 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 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 SocketTypeC > | |
| SocketTypeC * | accept () |
| Accept connection. More... | |
Additional Inherited Members | |
Public Types inherited from fawkes::Socket | |
| enum | AddrType { UNSPECIFIED , IPv4 , IPv6 } |
| Address type specification. More... | |
| enum | SocketType { TCP , UDP } |
| Socket type. More... | |
Static Public Attributes inherited from fawkes::Socket | |
| 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... | |
Protected Member Functions inherited from fawkes::Socket | |
| Socket (SocketType sock_type, float timeout=0.f) | |
| IPv4 Constructor. More... | |
| Socket () | |
| Constructor. More... | |
Protected Attributes inherited from fawkes::Socket | |
| AddrType | addr_type |
| Address type/family of socket. More... | |
| int | sock_fd |
| Socket file descriptor. More... | |
| float | timeout |
| Timeout in seconds for various operations. More... | |
| struct ::sockaddr_storage * | client_addr |
| Client address, set if connected. More... | |
| unsigned int | client_addr_len |
| length in bytes of client address. More... | |
Broadcast datagram socket.
An broadcast UDP socket on top of IPv4 (not available for IPv6).
Definition at line 32 of file datagram_broadcast.h.
| fawkes::BroadcastDatagramSocket::BroadcastDatagramSocket | ( | const char * | broadcast_addr_s, |
| unsigned short | port, | ||
| float | timeout = 0.f |
||
| ) |
Constructor.
| broadcast_addr_s | textual representation of the broadcast IP address to use for broadcast communication. NOT a hostname! |
| port | port |
| timeout | timeout, if 0 all operationsare blocking, otherwise it is tried for timeout seconds. |
Definition at line 51 of file datagram_broadcast.cpp.
Referenced by clone().
| fawkes::BroadcastDatagramSocket::BroadcastDatagramSocket | ( | BroadcastDatagramSocket & | datagram_socket | ) |
Copy constructor.
| datagram_socket | socket to copy. |
Definition at line 81 of file datagram_broadcast.cpp.
|
virtual |
Destructor.
Definition at line 73 of file datagram_broadcast.cpp.
|
virtual |
Bind socket.
This will make the socket listen for incoming traffic.
Definition at line 106 of file datagram_broadcast.cpp.
References fawkes::Socket::sock_fd.
Referenced by bind().
|
virtual |
Bind socket.
Can only be called on stream sockets.
| port | port to bind |
| SocketException | thrown if socket cannot bind, check errno for cause |
Reimplemented from fawkes::Socket.
Definition at line 129 of file datagram_broadcast.cpp.
References bind().
|
virtual |
Bind socket to a specific address.
| port | port to bind |
| ipaddr | textual IP address of a local interface to bind to, must match the address type passed to the constructor. |
| SocketException | thrown if socket cannot bind, check errno for cause |
Reimplemented from fawkes::Socket.
Definition at line 137 of file datagram_broadcast.cpp.
References bind().
|
virtual |
Clone socket.
Implements fawkes::Socket.
Definition at line 157 of file datagram_broadcast.cpp.
References BroadcastDatagramSocket().
| BroadcastDatagramSocket & fawkes::BroadcastDatagramSocket::operator= | ( | BroadcastDatagramSocket & | s | ) |
Assignment operator.
| s | socket to copy from |
Definition at line 93 of file datagram_broadcast.cpp.
References fawkes::Socket::operator=().
|
virtual |
Send data.
This will send the given data to the broadcast address specified in the constructor.
| buf | buffer to write |
| buf_len | length of buffer, number of bytes to write to stream |
Reimplemented from fawkes::Socket.
Definition at line 169 of file datagram_broadcast.cpp.
References fawkes::Exception::append(), and fawkes::Socket::send().
Referenced by send().
|
inlinevirtual |
Send message.
| buf | buffer with data to send |
| buf_len | length of buffer, all data will be send. |
| addr | addr to send data to. |
| addr_len | length of address |
Reimplemented from fawkes::Socket.
Definition at line 49 of file datagram_broadcast.h.
References send().