modified by ohneta
Dependents: HelloESP8266Interface_mine
Fork of NetworkSocketAPI by
SocketInterface Class Reference
SocketInterface class. More...
#include <SocketInterface.h>
Inherits Endpoint.
Public Member Functions | |
virtual int32_t | bind (uint16_t port) const =0 |
In server mode, set which port to listen on. | |
virtual int32_t | listen (void) const =0 |
In server mode, start listening to a port. | |
virtual int32_t | accept () const =0 |
In server mode, accept an incoming connection. | |
virtual int32_t | open ()=0 |
In client mode, open a connection to a remote host. | |
virtual int32_t | send (const void *data, uint32_t amount, uint32_t timeout_ms=15000)=0 |
In client or server mode send data. | |
virtual uint32_t | recv (void *data, uint32_t amount, uint32_t timeout_ms=15000)=0 |
In client or server mode receive data. | |
virtual int32_t | close () const =0 |
In client or server mode, close an open connection. | |
virtual uint32_t | getHandle () const =0 |
Get the socket's unique handle. | |
virtual const char * | getHostByName (const char *name) const =0 |
Get the ip address of a host by DNS lookup. | |
virtual void | setAddress (const char *addr)=0 |
Set the address of this endpoint. | |
virtual void | setPort (uint16_t port)=0 |
Set the port of this endpoint. | |
virtual void | setAddressPort (const char *addr, uint16_t port)=0 |
Set the address and port of this endpoint. | |
virtual const char * | getAddress (void) const =0 |
Get the IP address of this endpoint. | |
virtual uint16_t | getPort (void) const =0 |
Get the port of this endpoint. |
Detailed Description
SocketInterface class.
This is a common interface that is shared between all sockets that connect using the NetworkInterface.
Definition at line 94 of file SocketInterface.h.
Member Function Documentation
virtual int32_t accept | ( | ) | const [pure virtual] |
In server mode, accept an incoming connection.
- Parameters:
-
endpoint The endpoint we are listening to
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual int32_t bind | ( | uint16_t | port ) | const [pure virtual] |
In server mode, set which port to listen on.
- Parameters:
-
port The endpoint port
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual int32_t close | ( | ) | const [pure virtual] |
In client or server mode, close an open connection.
- Parameters:
-
endpoint The endpoint we want to connect to
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual const char* getAddress | ( | void | ) | const [pure virtual, inherited] |
Get the IP address of this endpoint.
- Returns:
- The IP address of this endpoint.
virtual uint32_t getHandle | ( | ) | const [pure virtual] |
Get the socket's unique handle.
- Returns:
- socket's handle number
virtual const char* getHostByName | ( | const char * | name ) | const [pure virtual, inherited] |
Get the ip address of a host by DNS lookup.
- Parameters:
-
name The name of a host you need an ip address for
- Returns:
- The ip address of the host otherwise NULL
virtual uint16_t getPort | ( | void | ) | const [pure virtual, inherited] |
Get the port of this endpoint.
- Returns:
- The port of this socket
virtual int32_t listen | ( | void | ) | const [pure virtual] |
In server mode, start listening to a port.
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual int32_t open | ( | ) | [pure virtual] |
In client mode, open a connection to a remote host.
- Parameters:
-
endpoint The endpoint we want to connect to
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual uint32_t recv | ( | void * | data, |
uint32_t | amount, | ||
uint32_t | timeout_ms = 15000 |
||
) | [pure virtual] |
In client or server mode receive data.
- Parameters:
-
data a buffer to store the data in amount The amount of data to receive timeout_ms The longest time to wait for the data
- Returns:
- The amount of data received
virtual int32_t send | ( | const void * | data, |
uint32_t | amount, | ||
uint32_t | timeout_ms = 15000 |
||
) | [pure virtual] |
In client or server mode send data.
- Parameters:
-
data A buffer of data to send amount The amount of data to send timeout_ms The longest amount of time this send can take
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual void setAddress | ( | const char * | addr ) | [pure virtual, inherited] |
Set the address of this endpoint.
- Parameters:
-
addr The endpoint address
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual void setAddressPort | ( | const char * | addr, |
uint16_t | port | ||
) | [pure virtual, inherited] |
Set the address and port of this endpoint.
- Parameters:
-
addr The endpoint address (supplied as an ip address). port The endpoint port
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
virtual void setPort | ( | uint16_t | port ) | [pure virtual, inherited] |
Set the port of this endpoint.
- Parameters:
-
port The endpoint port
- Returns:
- 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
Generated on Tue Jul 12 2022 18:45:36 by
![doxygen](doxygen.png)