Go to the documentation of this file.
63 ERROR(
"failed to initialize network client for device: "
70 ERROR(
"failed to create UDP socket");
76 ERROR(
"failed to convert to IPV4 address: " <<
arguments().get(
"HOST"));
85 ERROR(
"failed to bind socket");
210 DEBUG(
"got " << r <<
" bytes from: " <<
addr.addr <<
" at port: " <<
addr.port);
Result initialize()
Perform initialization.
Result createSocket(const SocketType type, int *socket)
Create new socket.
C int errno
The lvalue errno is used by many functions to return error values.
Result udpSend()
Send UDP packet.
C int atoi(const char *nptr)
Convert a string to an integer.
POSIX-compatible application.
IPV4::Address m_host
Host IP.
const ArgumentContainer & arguments() const
Get program arguments.
void setDescription(const String &desc)
Set program description.
Result readLine()
Read one line from standard input.
Defines a socket address and port pair.
ssize_t read(int fildes, void *buf, size_t nbyte)
Read from a file.
NetworkClient * m_client
Networking client.
C int recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t addrlen)
Receive a single datagram from a socket.
#define DEBUG(msg)
Output a debug message to standard output.
int printf(const char *format,...)
Output a formatted string to standard output.
static const Address toAddress(const char *address)
Convert string to IPV4 address.
slong Error
Error code defined in Error.h.
int strcmp(const char *dest, const char *src)
Compare two strings.
char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
virtual Result initialize()
Initialize the application.
C int sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen)
Send a single datagram to a remote host.
virtual ~NetCat()
Class destructor.
Result registerFlag(char arg, const char *name, const char *description)
Register a flag Argument.
Networking Client implementation.
Result bindSocket(const int sock, const IPV4::Address addr=0, const u16 port=0)
Bind socket to address/port.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
char m_lineBuf[64]
Line buffer.
ArgumentParser & parser()
Get program arguments parser.
#define ERROR(msg)
Output an error message.
C void exit(int status)
Terminate a process.
virtual Result exec()
Execute the application event loop.
NetCat(int argc, char **argv)
Class constructor.