44#ifndef COMMONCPP_UDP_H_
45#define COMMONCPP_UDP_H_
49#ifndef COMMONCPP_CONFIG_H_
53#ifndef COMMONCPP_STRING_H_
57#ifndef COMMONCPP_ADDRESS_H_
61#ifndef COMMONCPP_SOCKET_H_
103 {
return Socket::setKeepAlive(enable);}
147 {
return Socket::setLoopbackByFamily(enable, family);}
153 {
return Socket::setMulticastByFamily(enable, family);}
159 {
return Socket::setTimeToLiveByFamily(ttl, family);}
185 Socket::Error getInterfaceIndex(
const char *ethX,
int& InterfaceIndex);
205 ssize_t send(
const void *buf,
size_t len);
215 ssize_t receive(
void *buf,
size_t len,
bool reply =
false);
229 {
return getIPV4Peer(
port);}
242 inline ssize_t
peek(
void *buf,
size_t len)
243 {return ::recv(so, (
char *)buf, (
socksize_t)len, MSG_PEEK);}
248 void setPeer(
const char *service);
249 void connect(
const char *service);
255 Error disconnect(
void);
272 {
return Socket::setBroadcast(enable);}
387 inline ssize_t
send(
const void *buf,
size_t len)
394 {Socket::endSocket();}
405 {
return Socket::setMulticastByFamily(enable, family);}
408 {
return Socket::setTimeToLiveByFamily(ttl, family);}
430 return Socket::isPending(Socket::pendingOutput,
timeout);
435 {
return Socket::setRouting(enable);}
438 {
return Socket::setTypeOfService(tos);}
441 {
return Socket::setBroadcast(enable);}
495 return Socket::isPending(Socket::pendingInput,
timeout);
502 {Socket::endSocket();}
508 {
return Socket::setRouting(enable);}
511 {
return Socket::setMulticastByFamily(enable, family);}
514 {
return Socket::join(ia);}
517 {
return Socket::join(ia);}
520 inline Error join(
const IPV6Multicast &ia)
521 {
return Socket::join(ia);}
525 {
return Socket::drop(ia);}
528 inline Error drop(
const IPV6Multicast &ia)
529 {
return Socket::drop(ia);}
541 {return ::recv(so, (
char *)buf, (
socksize_t)len, 0);}
550 return Socket::isPending(Socket::pendingInput,
timeout);
604 Error disconnect(
void);
Network addresses and sockets related classes.
The network name and address objects are all derived from a common IPV4Address base class.
The broadcast address object is used to store the broadcast address for a specific subnet.
This object is used to hold the actual and valid internet address of a specific host machine that wil...
A specialization of IPV4Address that provides address validation for multicast addresses.
Representing a UDP socket used for subnet broadcasts, this class provides an alternate binding and se...
__DELETE_COPY(UDPBroadcast)
void setPeer(const IPV4Host &ia, tpport_t port)
Error setBroadcast(bool enable)
UDP duplex connections impliment a bi-directional point-to-point UDP session between two peer hosts.
Representing half of a two-way UDP connection, the UDP receiver can receive data from another peer ho...
Error join(const IPV4Multicast &ia)
__DELETE_COPY(UDPReceive)
ssize_t receive(void *buf, size_t len)
Receive a data packet from the connected peer host.
bool isInputReady(timeout_t timeout=TIMEOUT_INF)
See if input queue has data packets available.
Error drop(const IPV4Multicast &ia)
Error setMulticast(bool enable)
SOCKET getReceiver(void) const
Error join(const ucommon::Socket::address &ia)
Error setRouting(bool enable)
void endReceiver(void)
End receiver.
bool isPendingReceive(timeout_t timeout)
Check for pending data.
UDP sockets implement the TCP SOCK_DGRAM UDP protocol.
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
Error setKeepAlive(bool enable)
IPV4Host getPeer(tpport_t *port)
Error setMulticast(bool enable)
Set the multicast.
Error setTimeToLive(char ttl)
Set time to live.
Error setLoopback(bool enable)
Set the loopback.
Representing half of a two-way UDP connection, the UDP transmitter can broadcast data to another sele...
Error setRouting(bool enable)
Error setTypeOfService(Tos tos)
Error setTimeToLive(uint8_t ttl)
Error setMulticast(bool enable)
SOCKET getTransmitter(void)
__DELETE_COPY(UDPTransmit)
Error setBroadcast(bool enable)
ssize_t transmit(const char *buffer, size_t len)
Transmit "send" to use "connected" send rather than sendto.
ssize_t send(const void *buf, size_t len)
Transmit "send" to use "connected" send rather than sendto.
bool isOutputReady(unsigned long timeout=0l)
See if output queue is empty for sending more packets.
void endTransmitter(void)
Stop transmitter.
A generic socket address class.
Common C++ generic string class.
static shell::numericopt timeout('t', "--timeout", _TEXT("optional keyboard input timeout"), "seconds", 0)
in_port_t tpport_t
Transport Protocol Ports.
static shell::numericopt port('p', "--port", _TEXT("port to use"), "port", 0)
static uint8_t buffer[65536]