ESP8266_RTOS_SDK  v1.4.0
Data Structures | Macros | Typedefs | Enumerations | Functions
Network Espconn APIs

Network espconn APIs. More...

Data Structures

struct  _esp_tcp
 
struct  _esp_udp
 
struct  _remot_info
 
struct  espconn
 

Macros

#define ESPCONN_OK   0
 
#define ESPCONN_MEM   -1
 
#define ESPCONN_TIMEOUT   -3
 
#define ESPCONN_RTE   -4
 
#define ESPCONN_INPROGRESS   -5
 
#define ESPCONN_MAXNUM   -7
 
#define ESPCONN_ABRT   -8
 
#define ESPCONN_RST   -9
 
#define ESPCONN_CLSD   -10
 
#define ESPCONN_CONN   -11
 
#define ESPCONN_ARG   -12
 
#define ESPCONN_IF   -14
 
#define ESPCONN_ISCONN   -15
 

Typedefs

typedef void(* espconn_connect_callback) (void *arg)
 Connect callback. More...
 
typedef void(* espconn_reconnect_callback) (void *arg, sint8 err)
 Reconnect callback. More...
 
typedef struct _esp_tcp esp_tcp
 
typedef struct _esp_udp esp_udp
 
typedef struct _remot_info remot_info
 
typedef void(* espconn_recv_callback) (void *arg, char *pdata, unsigned short len)
 
typedef void(* espconn_sent_callback) (void *arg)
 
typedef void(* dns_found_callback) (const char *name, ip_addr_t *ipaddr, void *callback_arg)
 Callback which is invoked when a hostname is found. More...
 

Enumerations

enum  espconn_type { ESPCONN_INVALID = 0, ESPCONN_TCP = 0x10, ESPCONN_UDP = 0x20 }
 
enum  espconn_state {
  ESPCONN_NONE, ESPCONN_WAIT, ESPCONN_LISTEN, ESPCONN_CONNECT,
  ESPCONN_WRITE, ESPCONN_READ, ESPCONN_CLOSE
}
 
enum  espconn_option {
  ESPCONN_START = 0x00, ESPCONN_REUSEADDR = 0x01, ESPCONN_NODELAY = 0x02, ESPCONN_COPY = 0x04,
  ESPCONN_KEEPALIVE = 0x08, ESPCONN_END
}
 
enum  espconn_level { ESPCONN_KEEPIDLE, ESPCONN_KEEPINTVL, ESPCONN_KEEPCNT }
 
enum  {
  ESPCONN_IDLE = 0, ESPCONN_CLIENT, ESPCONN_SERVER, ESPCONN_BOTH,
  ESPCONN_MAX
}
 

Functions

void espconn_init (void)
 espconn initialization. More...
 
sint8 espconn_connect (struct espconn *espconn)
 Connect to a TCP server (ESP8266 acting as TCP client). More...
 
sint8 espconn_disconnect (struct espconn *espconn)
 Disconnect a TCP connection. More...
 
sint8 espconn_delete (struct espconn *espconn)
 Delete a transmission. More...
 
sint8 espconn_accept (struct espconn *espconn)
 Creates a TCP server (i.e. accepts connections). More...
 
sint8 espconn_create (struct espconn *espconn)
 Create UDP transmission. More...
 
uint8 espconn_tcp_get_max_con (void)
 Get maximum number of how many TCP connections are allowed. More...
 
sint8 espconn_tcp_set_max_con (uint8 num)
 Set the maximum number of how many TCP connection is allowed. More...
 
sint8 espconn_tcp_get_max_con_allow (struct espconn *espconn)
 Get the maximum number of TCP clients which are allowed to connect to ESP8266 TCP server. More...
 
sint8 espconn_tcp_set_max_con_allow (struct espconn *espconn, uint8 num)
 Set the maximum number of TCP clients allowed to connect to ESP8266 TCP server. More...
 
sint8 espconn_regist_time (struct espconn *espconn, uint32 interval, uint8 type_flag)
 Register timeout interval of ESP8266 TCP server. More...
 
sint8 espconn_get_connection_info (struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags)
 Get the information about a TCP connection or UDP transmission. More...
 
sint8 espconn_regist_sentcb (struct espconn *espconn, espconn_sent_callback sent_cb)
 Register data sent callback which will be called back when data are successfully sent. More...
 
sint8 espconn_regist_write_finish (struct espconn *espconn, espconn_connect_callback write_finish_fn)
 Register a callback which will be called when all sending TCP data is completely write into write-buffer or sent. More...
 
sint8 espconn_send (struct espconn *espconn, uint8 *psent, uint16 length)
 Send data through network. More...
 
sint8 espconn_sent (struct espconn *espconn, uint8 *psent, uint16 length)
 Send data through network. More...
 
sint16 espconn_sendto (struct espconn *espconn, uint8 *psent, uint16 length)
 Send UDP data. More...
 
sint8 espconn_regist_connectcb (struct espconn *espconn, espconn_connect_callback connect_cb)
 Register connection function which will be called back under successful TCP connection. More...
 
sint8 espconn_regist_recvcb (struct espconn *espconn, espconn_recv_callback recv_cb)
 register data receive function which will be called back when data are received. More...
 
sint8 espconn_regist_reconcb (struct espconn *espconn, espconn_reconnect_callback recon_cb)
 Register reconnect callback. More...
 
sint8 espconn_regist_disconcb (struct espconn *espconn, espconn_connect_callback discon_cb)
 Register disconnection function which will be called back under successful TCP disconnection. More...
 
uint32 espconn_port (void)
 Get an available port for network. More...
 
sint8 espconn_set_opt (struct espconn *espconn, uint8 opt)
 Set option of TCP connection. More...
 
sint8 espconn_clear_opt (struct espconn *espconn, uint8 opt)
 Clear option of TCP connection. More...
 
sint8 espconn_set_keepalive (struct espconn *espconn, uint8 level, void *optarg)
 Set configuration of TCP keep alive. More...
 
sint8 espconn_get_keepalive (struct espconn *espconn, uint8 level, void *optarg)
 Get configuration of TCP keep alive. More...
 
err_t espconn_gethostbyname (struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found)
 DNS function. More...
 
sint8 espconn_igmp_join (ip_addr_t *host_ip, ip_addr_t *multicast_ip)
 Join a multicast group. More...
 
sint8 espconn_igmp_leave (ip_addr_t *host_ip, ip_addr_t *multicast_ip)
 Leave a multicast group. More...
 
sint8 espconn_recv_hold (struct espconn *pespconn)
 Puts in a request to block the TCP receive function. More...
 
sint8 espconn_recv_unhold (struct espconn *pespconn)
 Unblock TCP receiving data (i.e. undo espconn_recv_hold). More...
 
void espconn_dns_setserver (char numdns, ip_addr_t *dnsserver)
 Set default DNS server. Two DNS server is allowed to be set. More...
 

Detailed Description

Network espconn APIs.

Macro Definition Documentation

#define ESPCONN_ABRT   -8

Connection aborted.

#define ESPCONN_ARG   -12

Illegal argument.

#define ESPCONN_CLSD   -10

Connection closed.

#define ESPCONN_CONN   -11

Not connected.

#define ESPCONN_IF   -14

UDP send error.

#define ESPCONN_INPROGRESS   -5

Operation in progress.

#define ESPCONN_ISCONN   -15

Already connected.

#define ESPCONN_MAXNUM   -7

Total number exceeds the maximum limitation.

#define ESPCONN_MEM   -1

Out of memory.

#define ESPCONN_OK   0

No error, everything OK.

#define ESPCONN_RST   -9

Connection reset.

#define ESPCONN_RTE   -4

Routing problem.

#define ESPCONN_TIMEOUT   -3

Timeout.

Typedef Documentation

typedef void(* dns_found_callback) (const char *name, ip_addr_t *ipaddr, void *callback_arg)

Callback which is invoked when a hostname is found.

Parameters
constchar *name : hostname
ip_addr_t*ipaddr : IP address of the hostname, or to be NULL if the name could not be found (or on any other error).
void*callback_arg : callback argument.
Returns
null
typedef void(* espconn_connect_callback) (void *arg)

Connect callback.

Callback which will be called if successful listening (ESP8266 as TCP server) or connection (ESP8266 as TCP client) callback, register by espconn_regist_connectcb.

Attention
The pointer "void *arg" may be different in different callbacks, please don't use this pointer directly to distinguish one from another in multiple connections, use remote_ip and remote_port in espconn instead.
Parameters
void*arg : pointer corresponding structure espconn.
Returns
null
typedef void(* espconn_reconnect_callback) (void *arg, sint8 err)

Reconnect callback.

Enter this callback when error occurred, TCP connection broke. This callback is registered by espconn_regist_reconcb.

Attention
The pointer "void *arg" may be different in different callbacks, please don't use this pointer directly to distinguish one from another in multiple connections, use remote_ip and remote_port in espconn instead.
Parameters
void*arg : pointer corresponding structure espconn.
sint8err : error code
  • ESCONN_TIMEOUT - Timeout
  • ESPCONN_ABRT - TCP connection aborted
  • ESPCONN_RST - TCP connection abort
  • ESPCONN_CLSD - TCP connection closed
  • ESPCONN_CONN - TCP connection
  • ESPCONN_HANDSHAKE - TCP SSL handshake fail
  • ESPCONN_PROTO_MSG - SSL application invalid
Returns
null
typedef void(* espconn_recv_callback) (void *arg, char *pdata, unsigned short len)

A callback prototype to inform about events for a espconn

Enumeration Type Documentation

Enumerator
ESPCONN_KEEPIDLE 

TCP keep-alive interval, unit : second.

ESPCONN_KEEPINTVL 

packet interval during TCP keep-alive, unit : second.

ESPCONN_KEEPCNT 

maximum packet retry count of TCP keep-alive.

Enumerator
ESPCONN_START 

no option, start enum.

ESPCONN_REUSEADDR 

free memory after TCP disconnection happen, need not wait 2 minutes.

ESPCONN_NODELAY 

disable nagle algorithm during TCP data transmission, quicken the data transmission.

ESPCONN_COPY 

enable espconn_regist_write_finish, enter write_finish_callback means that the data espconn_send sending was written into 2920 bytes write-buffer waiting for sending or already sent.

ESPCONN_KEEPALIVE 

enable TCP keep alive.

ESPCONN_END 

no option, end enum.

Current state of the espconn.

Enumerator
ESPCONN_NONE 

idle state, no connection

ESPCONN_WAIT 

ESP8266 is as TCP client, and waiting for connection

ESPCONN_LISTEN 

ESP8266 is as TCP server, and waiting for connection

ESPCONN_CONNECT 

connected

ESPCONN_WRITE 

sending data

ESPCONN_READ 

receiving data

ESPCONN_CLOSE 

connection closed

Protocol family and type of the espconn

Enumerator
ESPCONN_INVALID 

invalid type

ESPCONN_TCP 

TCP

ESPCONN_UDP 

UDP

Function Documentation

sint8 espconn_accept ( struct espconn espconn)

Creates a TCP server (i.e. accepts connections).

Parameters
structespconn *espconn : the network connection structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
  • ESPCONN_ISCONN - Already connected
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_clear_opt ( struct espconn espconn,
uint8  opt 
)

Clear option of TCP connection.

Parameters
structespconn *espconn : the TCP connection structure
uint8opt : enum espconn_option
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_connect ( struct espconn espconn)

Connect to a TCP server (ESP8266 acting as TCP client).

Attention
If espconn_connect fail, returns non-0 value, there is no connection, so it won't enter any espconn callback.
Parameters
structespconn *espconn : the network connection structure, the espconn to listen to the connection
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_RTE - Routing Problem
  • ESPCONN_MEM - Out of memory
  • ESPCONN_ISCONN - Already connected
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_create ( struct espconn espconn)

Create UDP transmission.

Attention
Parameter remote_ip and remote_port need to be set, do not set to be 0.
Parameters
structespconn *espconn : the UDP control block structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
  • ESPCONN_ISCONN - Already connected
  • ESPCONN_ARG - illegal argument, can't find the corresponding UDP transmission according to structure espconn
sint8 espconn_delete ( struct espconn espconn)

Delete a transmission.

Attention
Corresponding creation API :
  • TCP: espconn_accept,
  • UDP: espconn_create
Parameters
structespconn *espconn : the network connection structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding network according to structure espconn
  • ESPCONN_INPROGRESS - the connection is still in progress, please call espconn_disconnect to disconnect before delete it.
sint8 espconn_disconnect ( struct espconn espconn)

Disconnect a TCP connection.

Attention
Don't call this API in any espconn callback. If needed, please use system task to trigger espconn_disconnect.
Parameters
structespconn *espconn : the network connection structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
void espconn_dns_setserver ( char  numdns,
ip_addr_t *  dnsserver 
)

Set default DNS server. Two DNS server is allowed to be set.

Attention
Only if ESP8266 DHCP client is disabled (wifi_station_dhcpc_stop), this API can be used.
Parameters
charnumdns : DNS server ID, 0 or 1
ip_addr_t*dnsserver : DNS server IP
Returns
null
sint8 espconn_get_connection_info ( struct espconn pespconn,
remot_info **  pcon_info,
uint8  typeflags 
)

Get the information about a TCP connection or UDP transmission.

Parameters
structespconn *espconn : the network connection structure
remot_info**pcon_info : connect to client info
uint8typeflags : 0, regular server; 1, ssl server
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding transmission according to structure espconn
sint8 espconn_get_keepalive ( struct espconn espconn,
uint8  level,
void *  optarg 
)

Get configuration of TCP keep alive.

Parameters
structespconn *espconn : the TCP connection structure
uint8level : enum espconn_level
void*optarg : value of parameter
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
err_t espconn_gethostbyname ( struct espconn pespconn,
const char *  hostname,
ip_addr_t *  addr,
dns_found_callback  found 
)

DNS function.

Parse a hostname (string) to an IP address.

Parameters
structespconn *pespconn : espconn to parse a hostname.
constchar *hostname : the hostname.
ip_addr_t*addr : IP address.
dns_found_callbackfound : callback of DNS
Returns
err_t :
  • ESPCONN_OK - succeed
  • ESPCONN_INPROGRESS - error code : already connected
  • ESPCONN_ARG - error code : illegal argument, can't find network transmission according to structure espconn
sint8 espconn_igmp_join ( ip_addr_t *  host_ip,
ip_addr_t *  multicast_ip 
)

Join a multicast group.

Attention
This API can only be called after the ESP8266 station connects to a router.
Parameters
ip_addr_t*host_ip : IP of UDP host
ip_addr_t*multicast_ip : IP of multicast group
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
sint8 espconn_igmp_leave ( ip_addr_t *  host_ip,
ip_addr_t *  multicast_ip 
)

Leave a multicast group.

Attention
This API can only be called after the ESP8266 station connects to a router.
Parameters
ip_addr_t*host_ip : IP of UDP host
ip_addr_t*multicast_ip : IP of multicast group
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
void espconn_init ( void  )

espconn initialization.

Attention
Please call this API in user_init, if you need to use espconn functions.
Parameters
null
Returns
null
uint32 espconn_port ( void  )

Get an available port for network.

Parameters
null
Returns
Port number.
sint8 espconn_recv_hold ( struct espconn pespconn)

Puts in a request to block the TCP receive function.

Attention
The function does not act immediately; we recommend calling it while reserving 5*1460 bytes of memory. This API can be called more than once.
Parameters
structespconn *espconn : corresponding TCP connection structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn.
sint8 espconn_recv_unhold ( struct espconn pespconn)

Unblock TCP receiving data (i.e. undo espconn_recv_hold).

Attention
This API takes effect immediately.
Parameters
structespconn *espconn : corresponding TCP connection structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn.
sint8 espconn_regist_connectcb ( struct espconn espconn,
espconn_connect_callback  connect_cb 
)

Register connection function which will be called back under successful TCP connection.

Parameters
structespconn *espconn : the TCP connection structure
espconn_connect_callbackconnect_cb : registered callback function
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_regist_disconcb ( struct espconn espconn,
espconn_connect_callback  discon_cb 
)

Register disconnection function which will be called back under successful TCP disconnection.

Parameters
structespconn *espconn : the TCP connection structure
espconn_connect_callbackdiscon_cb : registered callback function
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_regist_reconcb ( struct espconn espconn,
espconn_reconnect_callback  recon_cb 
)

Register reconnect callback.

Attention
espconn_reconnect_callback is more like a network-broken error handler; it handles errors that occurs in any phase of the connection. For instance, if espconn_send fails, espconn_reconnect_callback will be called because the network is broken.
Parameters
structespconn *espconn : the TCP connection structure
espconn_reconnect_callbackrecon_cb : registered callback function
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_regist_recvcb ( struct espconn espconn,
espconn_recv_callback  recv_cb 
)

register data receive function which will be called back when data are received.

Parameters
structespconn *espconn : the network transmission structure
espconn_recv_callbackrecv_cb : registered callback function
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_regist_sentcb ( struct espconn espconn,
espconn_sent_callback  sent_cb 
)

Register data sent callback which will be called back when data are successfully sent.

Parameters
structespconn *espconn : the network connection structure
espconn_sent_callbacksent_cb : registered callback function which will be called if the data is successfully sent
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding transmission according to structure espconn
sint8 espconn_regist_time ( struct espconn espconn,
uint32  interval,
uint8  type_flag 
)

Register timeout interval of ESP8266 TCP server.

Attention
1. If timeout is set to 0, timeout will be disable and ESP8266 TCP server will not disconnect TCP clients has stopped communication. This usage of timeout=0, is deprecated.
2. This timeout interval is not very precise, only as reference.
Parameters
structespconn *espconn : the TCP connection structure
uint32interval : timeout interval, unit: second, maximum: 7200 seconds
uint8type_flag : 0, set for all connections; 1, set for a specific connection
  • If the type_flag set to be 0, please call this API after espconn_accept, before listened a TCP connection.
  • If the type_flag set to be 1, the first parameter *espconn is the specific connection.
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_regist_write_finish ( struct espconn espconn,
espconn_connect_callback  write_finish_fn 
)

Register a callback which will be called when all sending TCP data is completely write into write-buffer or sent.

Need to call espconn_set_opt to enable write-buffer first.

Attention
1. write-buffer is used to keep TCP data that waiting to be sent, queue number of the write-buffer is 8 which means that it can keep 8 packets at most. The size of write-buffer is 2920 bytes.
2. Users can enable it by using espconn_set_opt.
3. Users can call espconn_send to send the next packet in write_finish_callback instead of using espconn_sent_callback.
Parameters
structespconn *espconn : the network connection structure
espconn_connect_callbackwrite_finish_fn : registered callback function which will be called if the data is completely write into write buffer or sent.
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_send ( struct espconn espconn,
uint8 *  psent,
uint16  length 
)

Send data through network.

Attention
1. Please call espconn_send after espconn_sent_callback of the pre-packet.
2. If it is a UDP transmission, it is suggested to set espconn->proto.udp->remote_ip and remote_port before every calling of espconn_send.
Parameters
structespconn *espconn : the network connection structure
uint8*psent : pointer of data
uint16length : data length
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
  • ESPCONN_ARG - illegal argument, can't find the corresponding network transmission according to structure espconn
  • ESPCONN_MAXNUM - buffer of sending data is full
  • ESPCONN_IF - send UDP data fail
sint16 espconn_sendto ( struct espconn espconn,
uint8 *  psent,
uint16  length 
)

Send UDP data.

Parameters
structespconn *espconn : the UDP structure
uint8*psent : pointer of data
uint16length : data length
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
  • ESPCONN_MAXNUM - buffer of sending data is full
  • ESPCONN_IF - send UDP data fail
sint8 espconn_sent ( struct espconn espconn,
uint8 *  psent,
uint16  length 
)

Send data through network.

This API is deprecated, please use espconn_send instead.

Attention
1. Please call espconn_sent after espconn_sent_callback of the pre-packet.
2. If it is a UDP transmission, it is suggested to set espconn->proto.udp->remote_ip and remote_port before every calling of espconn_sent.
Parameters
structespconn *espconn : the network connection structure
uint8*psent : pointer of data
uint16length : data length
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_MEM - Out of memory
  • ESPCONN_ARG - illegal argument, can't find the corresponding network transmission according to structure espconn
  • ESPCONN_MAXNUM - buffer of sending data is full
  • ESPCONN_IF - send UDP data fail
sint8 espconn_set_keepalive ( struct espconn espconn,
uint8  level,
void *  optarg 
)

Set configuration of TCP keep alive.

Attention
In general, we need not call this API. If needed, please call it in espconn_connect_callback and call espconn_set_opt to enable keep alive first.
Parameters
structespconn *espconn : the TCP connection structure
uint8level : To do TCP keep-alive detection every ESPCONN_KEEPIDLE. If there is no response, retry ESPCONN_KEEPCNT times every ESPCONN_KEEPINTVL. If still no response, considers it as TCP connection broke, goes into espconn_reconnect_callback. Notice, keep alive interval is not precise, only for reference, it depends on priority.
void*optarg : value of parameter
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_set_opt ( struct espconn espconn,
uint8  opt 
)

Set option of TCP connection.

Attention
In general, we need not call this API. If call espconn_set_opt, please call it in espconn_connect_callback.
Parameters
structespconn *espconn : the TCP connection structure
uint8opt : option of TCP connection, refer to enum espconn_option
  • bit 0: 1: free memory after TCP disconnection happen need not wait 2 minutes;
  • bit 1: 1: disable nagle algorithm during TCP data transmission, quiken the data transmission.
  • bit 2: 1: enable espconn_regist_write_finish, enter write finish callback means the data espconn_send sending was written into 2920 bytes write-buffer waiting for sending or already sent.
  • bit 3: 1: enable TCP keep alive
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
uint8 espconn_tcp_get_max_con ( void  )

Get maximum number of how many TCP connections are allowed.

Parameters
null
Returns
Maximum number of how many TCP connections are allowed.
sint8 espconn_tcp_get_max_con_allow ( struct espconn espconn)

Get the maximum number of TCP clients which are allowed to connect to ESP8266 TCP server.

Parameters
structespconn *espconn : the TCP server structure
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_tcp_set_max_con ( uint8  num)

Set the maximum number of how many TCP connection is allowed.

Parameters
uint8num : Maximum number of how many TCP connection is allowed.
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn
sint8 espconn_tcp_set_max_con_allow ( struct espconn espconn,
uint8  num 
)

Set the maximum number of TCP clients allowed to connect to ESP8266 TCP server.

Parameters
structespconn *espconn : the TCP server structure
uint8num : Maximum number of TCP clients which are allowed
Returns
0 : succeed
Non-0 : error code
  • ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according to structure espconn