FreeNOS
Public Member Functions | Private Member Functions | Private Attributes
NetCat Class Reference

Network send/receive (cat) application. More...

#include <NetCat.h>

Inheritance diagram for NetCat:
POSIXApplication Application

Public Member Functions

 NetCat (int argc, char **argv)
 Class constructor. More...
 
virtual ~NetCat ()
 Class destructor. More...
 
virtual Result initialize ()
 Initialize the application. More...
 
virtual Result exec ()
 Execute the application event loop. More...
 
- Public Member Functions inherited from POSIXApplication
 POSIXApplication (int argc, char **argv)
 Class constructor. More...
 
virtual ~POSIXApplication ()
 Class destructor. More...
 
- Public Member Functions inherited from Application
 Application (int argc, char **argv)
 Class constructor. More...
 
virtual ~Application ()
 Class destructor. More...
 
virtual int run ()
 Run the application. More...
 

Private Member Functions

Result readLine ()
 Read one line from standard input. More...
 
Result udpSend ()
 Send UDP packet. More...
 
Result udpReceive ()
 
Result printLine ()
 

Private Attributes

NetworkClientm_client
 Networking client. More...
 
int m_socket
 Socket. More...
 
char m_lineBuf [64]
 Line buffer. More...
 
Size m_lineLen
 
IPV4::Address m_host
 Host IP. More...
 
u16 m_port
 Host port. More...
 

Additional Inherited Members

- Public Types inherited from Application
enum  Result {
  Success, NotFound, IOError, InvalidArgument,
  ShowUsage, TimedOut, OutOfMemory
}
 Result codes. More...
 
- Protected Member Functions inherited from POSIXApplication
virtual Result output (const char *string) const
 Print text to output. More...
 
int runProgram (const char *path, const char **argv)
 Runs an external program. More...
 
- Protected Member Functions inherited from Application
virtual Result output (String &string) const
 Print string to output. More...
 
ArgumentParserparser ()
 Get program arguments parser. More...
 
const ArgumentParserparser () const
 Get constant program arguments parser. More...
 
const ArgumentContainerarguments () const
 Get program arguments. More...
 
void setVersion (const String &version)
 Set program version. More...
 
- Protected Attributes inherited from Application
int m_argc
 Input argument count. More...
 
char ** m_argv
 Input argument values. More...
 

Detailed Description

Network send/receive (cat) application.

Definition at line 34 of file NetCat.h.

Constructor & Destructor Documentation

◆ NetCat()

NetCat::NetCat ( int  argc,
char **  argv 
)

◆ ~NetCat()

NetCat::~NetCat ( )
virtual

Class destructor.

Definition at line 49 of file NetCat.cpp.

Member Function Documentation

◆ exec()

NetCat::Result NetCat::exec ( )
virtual

Execute the application event loop.

Implements Application.

Definition at line 92 of file NetCat.cpp.

References Application::arguments(), DEBUG, printLine(), readLine(), Application::Success, udpReceive(), and udpSend().

◆ initialize()

NetCat::Result NetCat::initialize ( )
virtual

◆ printLine()

NetCat::Result NetCat::printLine ( )
private

Definition at line 121 of file NetCat.cpp.

References m_lineBuf, m_lineLen, printf(), and Application::Success.

Referenced by exec().

◆ readLine()

NetCat::Result NetCat::readLine ( )
private

Read one line from standard input.

Definition at line 129 of file NetCat.cpp.

References DEBUG, exit(), m_lineBuf, m_lineLen, printf(), read(), strcmp(), Application::Success, and ZERO.

Referenced by exec().

◆ udpReceive()

NetCat::Result NetCat::udpReceive ( )
private

◆ udpSend()

NetCat::Result NetCat::udpSend ( )
private

Send UDP packet.

Definition at line 179 of file NetCat.cpp.

References sockaddr::addr, DEBUG, errno, ERROR, Application::IOError, m_host, m_lineBuf, m_lineLen, m_port, m_socket, sendto(), strerror(), and Application::Success.

Referenced by exec().

Field Documentation

◆ m_client

NetworkClient* NetCat::m_client
private

Networking client.

Definition at line 75 of file NetCat.h.

Referenced by initialize().

◆ m_host

IPV4::Address NetCat::m_host
private

Host IP.

Definition at line 85 of file NetCat.h.

Referenced by initialize(), and udpSend().

◆ m_lineBuf

char NetCat::m_lineBuf[64]
private

Line buffer.

Definition at line 81 of file NetCat.h.

Referenced by printLine(), readLine(), udpReceive(), and udpSend().

◆ m_lineLen

Size NetCat::m_lineLen
private

Definition at line 82 of file NetCat.h.

Referenced by printLine(), readLine(), and udpSend().

◆ m_port

u16 NetCat::m_port
private

Host port.

Definition at line 88 of file NetCat.h.

Referenced by initialize(), and udpSend().

◆ m_socket

int NetCat::m_socket
private

Socket.

Definition at line 78 of file NetCat.h.

Referenced by initialize(), udpReceive(), and udpSend().


The documentation for this class was generated from the following files: