55 ERROR(
"failed to initialize network client for device "
56 << dev <<
": result = " << (
int) result);
64 ERROR(
"failed to create UDP socket on device " << dev <<
65 ": result = " << (
int) result);
73 ERROR(
"failed to bind socket to UDP port " << port <<
74 " on device " << dev <<
": result = " << (
int) result);
107 for (
Size i = 0; i < count;)
115 ERROR(
"failed to send multiple UDP packets: result = " << (
int) r);
const ArgumentContainer & arguments() const
Get program arguments.
ArgumentParser & parser()
Get program arguments parser.
const char * get(const char *name) const
Get argument by name.
void setDescription(const String &desc)
Set program description.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
static const String toString(const Address address)
Convert address to string.
static const Address toAddress(const char *address)
Convert string to IPV4 address.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
virtual Result exec()
Execute the application event loop.
virtual Result initialize()
Initialize the application.
Result udpSendMultiple(const struct iovec *vec, const Size count, const struct sockaddr &addr) const
Send multiple UDP packets.
static const Size PacketSize
Size of each packet to send in bytes.
static const Size QueueSize
Number of packets to submit for transmission each iteration.
virtual ~NetSend()
Class destructor.
NetworkClient * m_client
Network client.
NetSend(int argc, char **argv)
Class constructor.
Networking Client implementation.
Result bindSocket(const int sock, const IPV4::Address addr=0, const u16 port=0)
Bind socket to address/port.
Result initialize()
Perform initialization.
Result createSocket(const SocketType type, int *socket)
Create new socket.
static const Size PayloadBufferSize
Size of payload memory buffer.
static const Size MaxPackets
Maximum number of packets available.
POSIX-compatible application.
long toLong(const Number::Base base=Number::Dec) const
Convert the String to a signed long integer.
C char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
C int errno
The lvalue errno is used by many functions to return error values.
C int sendmsg(int sockfd, const struct msghdr *msg, int flags)
Send multiple datagrams to a remote host.
#define ERROR(msg)
Output an error message.
unsigned short u16
Unsigned 16-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
#define DEBUG(msg)
Output a debug message to standard output.
unsigned char u8
Unsigned 8-bit number.
Input/Output vector for multi-packet operations.
Describes one or more datagrams.
Defines a socket address and port pair.