libcyberradio  22.01.24
ClientSocket Class Reference

Client socket class. More...

#include <ClientSocket.h>

Public Member Functions

 ClientSocket (const std::string &hostname, unsigned int port, bool debug=true)
 Constructs a ClientSocket object. More...
 
virtual ~ClientSocket ()
 Destroys a ClientSocket object.
 
bool isConnected (void)
 Gets whether or not the socket is connected. More...
 
bool connectToServer (void)
 Connects to the server. More...
 
bool disconnect (void)
 Disconnects from the server. More...
 
bool sendCmd (const std::string &cmd)
 Sends a command to the server. More...
 
bool getRsp (BasicStringList &rsp, float timeout)
 Gets a command response from the server. More...
 
bool sendCmdAndGetRsp (const std::string &cmd, BasicStringList &rsp, float timeout, bool print)
 Sends a command to the server and gets the response. More...
 
bool sendCmdAndGetRsp (const std::string &cmd, BasicStringList &rsp, float timeout)
 Sends a command to the server and gets the response. More...
 

Detailed Description

Client socket class.

Definition at line 43 of file ClientSocket.h.

Constructor & Destructor Documentation

◆ ClientSocket()

ClientSocket ( const std::string &  hostname,
unsigned int  port,
bool  debug = true 
)

Constructs a ClientSocket object.

Parameters
hostnameHost name
portUDP port
debugWhether or not to produce debug output

Definition at line 19 of file ClientSocket.cpp.

Member Function Documentation

◆ connectToServer()

bool connectToServer ( void  )

Connects to the server.

Returns
True if the action succeeds, false otherwise.

Definition at line 32 of file ClientSocket.cpp.

◆ disconnect()

bool disconnect ( void  )

Disconnects from the server.

Returns
True if the action succeeds, false otherwise.

Definition at line 81 of file ClientSocket.cpp.

◆ getRsp()

bool getRsp ( BasicStringList rsp,
float  timeout 
)

Gets a command response from the server.

Parameters
rspA list of response strings
timeoutResponse timeout, in seconds
Returns
True if the action succeeds, false otherwise.

Definition at line 107 of file ClientSocket.cpp.

◆ isConnected()

bool isConnected ( void  )
inline

Gets whether or not the socket is connected.

Returns
True if the socket is connected, false otherwise.

Definition at line 62 of file ClientSocket.h.

◆ sendCmd()

bool sendCmd ( const std::string &  cmd)

Sends a command to the server.

Parameters
cmdThe command string to send
Returns
True if the action succeeds, false otherwise.

Definition at line 99 of file ClientSocket.cpp.

◆ sendCmdAndGetRsp() [1/2]

bool sendCmdAndGetRsp ( const std::string &  cmd,
BasicStringList rsp,
float  timeout,
bool  print 
)

Sends a command to the server and gets the response.

Parameters
cmdThe command string to send
rspA list of response strings
timeoutResponse timeout, in seconds
printWhether or not to print the result
Returns
True if the action succeeds, false otherwise.

Definition at line 126 of file ClientSocket.cpp.

◆ sendCmdAndGetRsp() [2/2]

bool sendCmdAndGetRsp ( const std::string &  cmd,
BasicStringList rsp,
float  timeout 
)

Sends a command to the server and gets the response.

Parameters
cmdThe command string to send
rspA list of response strings
timeoutResponse timeout, in seconds
Returns
True if the action succeeds, false otherwise.

Definition at line 122 of file ClientSocket.cpp.


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