Socket
The Socket class extends the Stream class and provides an abstraction for working with network sockets, supporting both stream and datagram socket types. It offers functionality for opening and closing sockets, connecting to remote addresses, and accepting incoming connections. The class supports socket-specific operations such as selecting sockets for activity, setting timeouts, and configuring blocking and delay behaviors.
#include <core/TellusimSocket.h>
Inheritance
- Inherits from Stream
Constructors
explicit Socket(Type type = TypeStream)
Methods
Open/close socket.
bool open(uint16_t port, uint16_t num = 32)
bool open(const char *name, uint16_t port)
bool open(const String &name, uint16_t port)
void close()
Stream socket.
bool connect(uint32_t sec, uint32_t usec = 0)
virtual bool accept(Socket &socket)
Socket operations.
bool select(uint32_t sec, uint32_t usec = 0)
Socket timeout.
bool setTimeout(uint32_t sec)
uint32_t getTimeout() const
Socket blocking.
bool setBlock(bool block)
bool getBlock() const
Sockey delay.
bool setDelay(bool delay)
bool getDelay() const
Socket parameters.
void setName(const char *name)
void setName(const String &name)
uint16_t getPort() const
int32_t getFD() const
Type getType() const
Socket utils.
static String getAddress(const char *delimiter = nullptr)
Enums
Type
Socket type.
Name | Value |
---|---|
TypeStream | 0 |
TypeDatagram | 1 |
NumTypes | 2 |