A base class representing a network socket.
More...
#include <socket.h>
|
void | Close () |
| Closes the socket.
|
|
std::string | GetIP () const |
| Gets the IP address associated with the socket. More...
|
|
void | GetIpArray (uint8_t *ip) const |
| Gets the IP address associated with the socket as an array of bytes. More...
|
|
uint16_t | GetPort () const |
| Gets the port number associated with the socket. More...
|
|
std::string | GetAddress () const |
| Gets the full address (IP:Port) associated with the socket. More...
|
|
std::string | GetSocketType () const |
| Gets the socket type. More...
|
|
std::chrono::system_clock::time_point | GetLastRecievedTime () const |
| Gets the time when the socket last received data. More...
|
|
void | Send (const std::string &msg) const |
| Sends a message over the socket. More...
|
|
void | Send (const std::vector< unsigned char > &msg) const |
| Sends a message over the socket. More...
|
|
void | UDPSend (const std::string &msg) const |
| Sends a UDP message over the socket. More...
|
|
void | UDPSend (const std::vector< unsigned char > &msg) const |
| Sends a UDP message over the socket. More...
|
|
void | UpdateLastRecievedTime () |
| Updates the last received time to the current system time.
|
|
virtual void | WTF_WHY_AM_I_HERE_1337 () |
| Empty virtual function required for static_cast in C++. More...
|
|
A base class representing a network socket.
Definition at line 14 of file socket.h.
◆ GetAddress()
std::string Net::Socket::GetAddress |
( |
| ) |
const |
Gets the full address (IP:Port) associated with the socket.
- Returns
- The address as a string in the format "IP:Port".
Definition at line 44 of file socket.cpp.
◆ GetIP()
std::string Net::Socket::GetIP |
( |
| ) |
const |
Gets the IP address associated with the socket.
- Returns
- The IP address as a string.
Definition at line 25 of file socket.cpp.
◆ GetIpArray()
void Net::Socket::GetIpArray |
( |
uint8_t * |
ip | ) |
const |
Gets the IP address associated with the socket as an array of bytes.
- Parameters
-
ip | Pointer to an array where the IP will be stored. |
Definition at line 34 of file socket.cpp.
◆ GetLastRecievedTime()
std::chrono::system_clock::time_point Net::Socket::GetLastRecievedTime |
( |
| ) |
const |
Gets the time when the socket last received data.
- Returns
- The last received time as a system_clock::time_point.
Definition at line 73 of file socket.cpp.
◆ GetPort()
uint16_t Net::Socket::GetPort |
( |
| ) |
const |
Gets the port number associated with the socket.
- Returns
- The port number.
Definition at line 39 of file socket.cpp.
◆ GetSocketType()
std::string Net::Socket::GetSocketType |
( |
| ) |
const |
Gets the socket type.
- Returns
- The socket type as a string.
Definition at line 49 of file socket.cpp.
◆ Send() [1/2]
void Net::Socket::Send |
( |
const std::string & |
msg | ) |
const |
Sends a message over the socket.
- Parameters
-
msg | The message to send as a string. |
Definition at line 80 of file socket.cpp.
◆ Send() [2/2]
void Net::Socket::Send |
( |
const std::vector< unsigned char > & |
msg | ) |
const |
Sends a message over the socket.
- Parameters
-
msg | The message to send as a vector of unsigned chars. |
Definition at line 87 of file socket.cpp.
◆ UDPSend() [1/2]
void Net::Socket::UDPSend |
( |
const std::string & |
msg | ) |
const |
Sends a UDP message over the socket.
- Parameters
-
msg | The message to send as a string. |
Definition at line 94 of file socket.cpp.
◆ UDPSend() [2/2]
void Net::Socket::UDPSend |
( |
const std::vector< unsigned char > & |
msg | ) |
const |
Sends a UDP message over the socket.
- Parameters
-
msg | The message to send as a vector of unsigned chars. |
Definition at line 103 of file socket.cpp.
◆ WTF_WHY_AM_I_HERE_1337()
virtual void Net::Socket::WTF_WHY_AM_I_HERE_1337 |
( |
| ) |
|
|
inlinevirtual |
Empty virtual function required for static_cast in C++.
In C++, you cannot directly cast a base class pointer (std::shared_ptr<Net::Socket>) to a derived class pointer (std::shared_ptr<GPCM::Client>) using static_cast when the base class is not polymorphic (i.e., it doesn't have at least one virtual function). This is because static_cast requires a polymorphic base class for a safe cast.
Definition at line 102 of file socket.h.
◆ _address
struct sockaddr_in Net::Socket::_address |
|
protected |
The socket address information.
Definition at line 17 of file socket.h.
◆ _mutex
std::mutex Net::Socket::_mutex |
|
mutableprotected |
Mutex for thread safety.
Definition at line 20 of file socket.h.
◆ _recieved_time
std::chrono::system_clock::time_point Net::Socket::_recieved_time |
|
protected |
Time when data was last received.
Definition at line 19 of file socket.h.
◆ _socket
The socket file descriptor.
Definition at line 17 of file socket.h.
The documentation for this class was generated from the following files: