EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1436 background imageLoading...
Page #1436 background image
Chapter 4. API Guides
References
A wide range of BSD Sockets reference material is available, including:
Single UNIX Specification BSD Sockets page
Berkeley Sockets Wikipedia page
Examples
A number of ESP-IDF examples show how to use the BSD Sockets APIs:
protocols/sockets/tcp_server
protocols/sockets/tcp_client
protocols/sockets/udp_server
protocols/sockets/udp_client
protocols/sockets/udp_multicast
protocols/http_request (Note: this is a simplified example of using a TCP socket to send an HTTP request.
The ESP HTTP Client is a much better option for sending HTTP requests.)
Supported functions
The following BSD socket API functions are supported. For full details see lwip/lwip/src/include/lwip/sockets.h.
socket()
bind()
accept()
shutdown()
getpeername()
getsockopt() & setsockopt() (see Socket Options)
close() (via Virtual filesystem component)
read(), readv(), write(), writev() (via Virtual filesystem component)
recv(), recvmsg(), recvfrom()
send(), sendmsg(), sendto()
select() (via Virtual filesystem component)
poll() (Note: on ESP-IDF, poll() is implemented by calling select internally, so using select()
directly is recommended if a choice of methods is available.)
fcntl() (see fcntl)
Non-standard functions:
ioctl() (see ioctls)
Note: Some lwIP application sample code uses prefixed versions of BSD APIs, for example lwip_socket()
instead of the standard socket(). Both forms can be used with ESP-IDF, but using standard names is recom-
mended.
Socket Error Handling
BSD Socket error handling code is very important for robust socket applications. Normally the socket error handling
involves the following aspects:
Detecting the error.
Geting the error reason code.
Handle the error according to the reason code.
In lwIP, we have two different scenarios of handling socket errors:
Socket API returns an error. For more information, see Socket API Errors.
Espressif Systems 1425
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish