General tcp socket class, fully async using libevent.
More...
#include <Socket.h>
General tcp socket class, fully async using libevent.
| trippingcyril::net::Socket::Socket |
( |
const Module * |
module | ) |
|
General constructor
- Parameters
-
| module | The module to register this socket on |
| trippingcyril::net::Socket::Socket |
( |
struct bufferevent * |
event | ) |
|
Constructor used to create incoming connections
- See Also
- Listener
| virtual trippingcyril::net::Socket::~Socket |
( |
| ) |
|
|
virtual |
General deconstructor, will close the connection if needed
| void trippingcyril::net::Socket::Close |
( |
| ) |
|
|
overridevirtual |
| bool trippingcyril::net::Socket::Connect |
( |
const String & |
hostname, |
|
|
uint16_t |
port, |
|
|
bool |
ssl = false, |
|
|
double |
timeout = 60.0 |
|
) |
| |
Connect the actual socket
- Parameters
-
| hostname | The hostname to connect to |
| port | The port to connect to |
| ssl | True if you want to use a ssl socket |
| timeout | Connect/read/write timeout |
- Returns
- False if already connected or trying to connect
| bool trippingcyril::net::Socket::Connect |
( |
const IPAddress * |
ip, |
|
|
uint16_t |
port, |
|
|
bool |
ssl = false, |
|
|
double |
timeout = 60.0 |
|
) |
| |
Connect the actual socket
- Parameters
-
| ip | The ip address to connect to |
| port | The port to connect to |
| ssl | True if you want to use a ssl socket |
| timeout | Connect/read/write timeout |
- Returns
- False if already connected or trying to connect
| virtual void trippingcyril::net::Socket::Connected |
( |
| ) |
|
|
inlineprotectedvirtual |
| void trippingcyril::net::Socket::DisableTimeout |
( |
| ) |
|
|
inline |
Used to disable the read/write timeouts currently set
| virtual void trippingcyril::net::Socket::Disconnected |
( |
| ) |
|
|
inlineprotectedvirtual |
| const IPAddress* trippingcyril::net::Socket::GetIP |
( |
| ) |
const |
Get the ip address of the remote end
| bool trippingcyril::net::Socket::IsConnected |
( |
| ) |
const |
|
inline |
- Returns
- True if socket is connected
| virtual void trippingcyril::net::Socket::OnWrite |
( |
size_t |
bytes_left | ) |
|
|
inlineprotectedvirtual |
This will get called once it wrote something to the actual socket
- Parameters
-
| bytes_left | Amount of bytes left to write in our buffer |
| virtual size_t trippingcyril::net::Socket::ReadData |
( |
const char * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineprotectedvirtual |
ReadData callback, will be called if read line mode is off. Return the amount of bytes that should be consumed. In case you are not done yet processing all the data set read_more to 1.
| virtual void trippingcyril::net::Socket::ReadLine |
( |
const String & |
line | ) |
|
|
inlineprotectedvirtual |
ReadLine callback, will be called if read line mode is on. Return data up until a newline from the socket.
| void trippingcyril::net::Socket::SetReadLine |
( |
bool |
b | ) |
|
|
inline |
Enable/disable read line mode, decides if ReadLine or ReadData should be called
| bool trippingcyril::net::Socket::SetTCPKeepAlive |
( |
bool |
enable, |
|
|
int |
delay |
|
) |
| |
|
protected |
Allows you to set a custom tcp keep alive interval, or disable tcp keep alive all together.
| bool trippingcyril::net::Socket::SetTCPNoDelay |
( |
bool |
enable | ) |
|
|
protected |
Allows you to determine if the tcp no delay feature should be used or not
| void trippingcyril::net::Socket::SetTimeout |
( |
double |
timeout | ) |
|
Used to set a read/write timeout
| virtual void trippingcyril::net::Socket::Timeout |
( |
| ) |
|
|
inlineprotectedvirtual |
| int trippingcyril::net::Socket::Write |
( |
const char * |
data, |
|
|
size_t |
len |
|
) |
| |
|
overridevirtual |
Write data to socket
- Parameters
-
| data | The actual data |
| len | The length of the data |
- Returns
- Amount of bytes written, should be equal to len
Implements trippingcyril::Writer.
| size_t trippingcyril::net::Socket::next_read |
|
protected |
Tells the underlying socket how many bytes you need for your next operation using this is not required, but doing so may improve performance. Leaving this at the default (0) will not use this feature. This feature of course only works for the non read line mode
| uint8_t trippingcyril::net::Socket::read_more |
|
protected |
Determines if ReadData should get called again or not.
The documentation for this class was generated from the following file: