modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of NetworkSocketAPI by NetworkSocketAPI

Embed: (wiki syntax)

« Back to documentation index

SocketInterface Class Reference

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:
endpointThe 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:
portThe 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:
endpointThe 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:
nameThe 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:
endpointThe 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:
dataa buffer to store the data in
amountThe amount of data to receive
timeout_msThe 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:
dataA buffer of data to send
amountThe amount of data to send
timeout_msThe 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:
addrThe 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:
addrThe endpoint address (supplied as an ip address).
portThe 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:
portThe endpoint port
Returns:
0 on success, -1 on failure (when an hostname cannot be resolved by DNS).