Secure Sockets

General Description

All API functions except cy_socket_init and cy_socket_deinit are thread-safe.

All API functions are blocking API functions.

Secure Sockets Library creates a worker thread for processing events from the network stack. The priority of the thread is CY_RTOS_PRIORITY_ABOVENORMAL. The macro CY_RTOS_PRIORITY_ABOVENORMAL is defined in abstraction-rtos/include/COMPONENT_FREERTOS/cyabs_rtos_impl.h.

Functions

cy_rslt_t cy_socket_init (void)
 Does general allocation and initialization of resources needed for the library. More...
 
cy_rslt_t cy_socket_deinit (void)
 Releases the resources allocated in cy_socket_init function. More...
 
cy_rslt_t cy_socket_create (int domain, int type, int protocol, cy_socket_t *handle)
 Creates a new socket. More...
 
cy_rslt_t cy_socket_connect (cy_socket_t handle, cy_socket_sockaddr_t *address, uint32_t address_length)
 Connects a TCP/TLS socket to the specified server IP address and port. More...
 
cy_rslt_t cy_socket_disconnect (cy_socket_t handle, uint32_t timeout)
 Disconnects a TCP/TLS socket's remote connection. More...
 
cy_rslt_t cy_socket_bind (cy_socket_t handle, cy_socket_sockaddr_t *address, uint32_t address_length)
 Binds the socket to the given socket address. More...
 
cy_rslt_t cy_socket_listen (cy_socket_t handle, int backlog)
 Listens for TCP/TLS socket connections and limits the queue of incoming connections. More...
 
cy_rslt_t cy_socket_accept (cy_socket_t handle, cy_socket_sockaddr_t *address, uint32_t *address_length, cy_socket_t *socket)
 Accepts a new TCP/TLS connection on a socket. More...
 
cy_rslt_t cy_socket_send (cy_socket_t handle, const void *buffer, uint32_t length, int flags, uint32_t *bytes_sent)
 Sends data over a connected TCP/TLS socket. More...
 
cy_rslt_t cy_socket_sendto (cy_socket_t handle, const void *buffer, uint32_t length, int flags, const cy_socket_sockaddr_t *dest_addr, uint32_t address_length, uint32_t *bytes_sent)
 Sends a UDP datagram over a specified socket. More...
 
cy_rslt_t cy_socket_recv (cy_socket_t handle, void *buffer, uint32_t length, int flags, uint32_t *bytes_received)
 Receives the data from a connected TCP/TLS socket. More...
 
cy_rslt_t cy_socket_recvfrom (cy_socket_t handle, void *buffer, uint32_t length, int flags, cy_socket_sockaddr_t *src_addr, uint32_t *src_addr_length, uint32_t *bytes_received)
 Receives a UDP datagram for the specified socket. More...
 
cy_rslt_t cy_socket_setsockopt (cy_socket_t handle, int level, int optname, const void *optval, uint32_t optlen)
 Sets a particular socket option. More...
 
cy_rslt_t cy_socket_getsockopt (cy_socket_t handle, int level, int optname, void *optval, uint32_t *optlen)
 Gets the value of a particular socket option. More...
 
cy_rslt_t cy_socket_gethostbyname (const char *hostname, cy_socket_ip_version_t ip_ver, cy_socket_ip_address_t *addr)
 Resolves a host name using Domain Name Service. More...
 
cy_rslt_t cy_socket_poll (cy_socket_t handle, uint32_t *rwflags, uint32_t timeout)
 Checks whether data is available on the socket. More...
 
cy_rslt_t cy_socket_shutdown (cy_socket_t handle, int how)
 Shuts down the send and/or receive operation on the given TCP socket. More...
 
cy_rslt_t cy_socket_delete (cy_socket_t handle)
 Releases the resources allocated for the socket by the cy_socket_create function. More...
 

Function Documentation

◆ cy_socket_init()

cy_rslt_t cy_socket_init ( void  )

Does general allocation and initialization of resources needed for the library.

This API function must be called before using any other socket API.

Note
cy_socket_init and cy_socket_deinit API functions are not thread-safe. The caller must ensure that these two API functions are not invoked simultaneously from different threads.
Returns
CY_RSLT_SUCCESS on success; an error code on failure.

◆ cy_socket_deinit()

cy_rslt_t cy_socket_deinit ( void  )

Releases the resources allocated in cy_socket_init function.

Prior to calling this API function, all created sockets must be disconnected and deleted.

Note
cy_socket_init and cy_socket_deinit API functions are not thread-safe. The caller must ensure that these two API functions are not invoked simultaneously from different threads.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error code related to this API function is: CY_RSLT_MODULE_SECURE_SOCKETS_NOT_INITIALIZED

◆ cy_socket_create()

cy_rslt_t cy_socket_create ( int  domain,
int  type,
int  protocol,
cy_socket_t handle 
)

Creates a new socket.

Note
  1. cy_socket_create() function creates a dual-stack socket if domain passed is CY_SOCKET_DOMAIN_AF_INET6.
  2. Secure Sockets Library configures default send and receive timeout values to 10 seconds for a newly created socket. These default values can be overridden using the cy_socket_setsockopt API. Adjust the default timeout values based on the network speed or use case. For example, to change the send timeout, use the CY_SOCKET_SO_SNDTIMEO socket option; similarly, for receive timeout, use the CY_SOCKET_SO_RCVTIMEO socket option.
  3. Secure Socket Library sets default TLS authentication mode for TLS client sockets to CY_SOCKET_TLS_VERIFY_REQUIRED. For TLS server sockets, it sets the default TLS authentication mode to CY_SOCKET_TLS_VERIFY_NONE. To override the default authentication mode, use cy_socket_setsockopt with the CY_SOCKET_SO_TLS_AUTH_MODE socket option.
  4. To use a socket for multicast operations over SoftAP interface, user must bind the socket to the SoftAP interface using CY_SOCKET_SO_BINDTODEVICE socket option after creating the socket.

Valid type/protocol combinations are:

Parameters
[in]domainProtocol family to be used by the socket. Refer CY_SOCKET_DOMAIN_AF_INET and CY_SOCKET_DOMAIN_AF_INET6.
[in]typeProtocol type to be used by the socket. Refer CY_SOCKET_TYPE_DGRAM and CY_SOCKET_TYPE_STREAM.
[in]protocolTransport protocol to be used by the socket. Refer CY_SOCKET_IPPROTO_TCP, CY_SOCKET_IPPROTO_UDP, and CY_SOCKET_IPPROTO_TLS.
[out]handleSocket handle; contents of this handle are specific to the socket layer implementation.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. On success, it also returns the socket handle. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_NOMEM
CY_RSLT_MODULE_SECURE_SOCKETS_NETIF_DOES_NOT_EXIST

◆ cy_socket_connect()

cy_rslt_t cy_socket_connect ( cy_socket_t  handle,
cy_socket_sockaddr_t address,
uint32_t  address_length 
)

Connects a TCP/TLS socket to the specified server IP address and port.

This API function is a blocking call.

For secure (TLS) sockets, before calling this API function, the following TLS configuration can be set:

  1. RootCA using the cy_tls_load_global_root_ca_certificates or cy_socket_setsockopt API function with CY_SOCKET_SO_TRUSTED_ROOTCA_CERTIFICATE.
  2. Certificate/key pair with cy_tls_create_identity and cy_socket_setsockopt with CY_SOCKET_SO_TLS_IDENTITY.
  3. For TLS client sockets, the default authentication mode set is CY_SOCKET_TLS_VERIFY_REQUIRED. To override the default authentication mode, use cy_socket_setsockopt with the CY_SOCKET_SO_TLS_AUTH_MODE socket option.
  4. The default mbed TLS configuration provided by the Wi-Fi Middleware Core Library disables the validity period verification of the certificates. To perform this verification, enable MBEDTLS_HAVE_TIME_DATE in the mbedtls_user_config.h file. Ensure that the system time is set prior to the cy_socket_connect() function call. To set the system time, get the time from the NTP server and set the system's RTC time using cyhal_rtc_init(), cyhal_rtc_write() and cy_set_rtc_instance() functions. See the Time Support Details for reference. See the Code Snippet 12: Get the current time from the NTP server - Send an NTP request packet to the NTP server, and receive an NTP reply packet. to get the time from NTP server.
Note
This is applicable if Secure Sockets Library is built for lwIP network stack. If this function returns CY_RSLT_MODULE_SECURE_SOCKETS_CLOSED error, the socket handle cannot be reused to establish the connection. The caller should invoke cy_socket_delete API function to delete the current socket handle, and create a new socket handle using cy_socket_create API function to re-establish the connection. This is required, due to the limitation of lwIP stack.
Parameters
[in]handleSocket handle returned by the cy_socket_create API function.
[in]addressPointer to the cy_socket_sockaddr_t structure that contains the address to connect the socket to. Refer cy_socket_ip_address_t for IP address endienness.
[in]address_lengthLength of the cy_socket_sockaddr_t structure.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_TLS_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TCPIP_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TIMEOUT
CY_RSLT_MODULE_SECURE_SOCKETS_NOMEM

◆ cy_socket_disconnect()

cy_rslt_t cy_socket_disconnect ( cy_socket_t  handle,
uint32_t  timeout 
)

Disconnects a TCP/TLS socket's remote connection.

Timeout is not supported by all network stacks. If the underlying network stack does not support the timeout option, this function returns after a clean disconnect. lwIP does not support the timeout option.

Note
Ensure that this API function is also called when the socket send/receive API fails with the error CY_RSLT_MODULE_SECURE_SOCKETS_CLOSED.
Parameters
[in]handleSocket handle returned by either the cy_socket_create API function for client sockets, or by the cy_socket_accept API function for accepted sockets.
[in]timeoutMaximum amount of time to wait in milliseconds for a clean disconnect. When the timeout is zero, the function returns after a clean disconnect or when the operation results in an error.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_NOT_CONNECTED

◆ cy_socket_bind()

cy_rslt_t cy_socket_bind ( cy_socket_t  handle,
cy_socket_sockaddr_t address,
uint32_t  address_length 
)

Binds the socket to the given socket address.

Parameters
[in]handleSocket handle returned by the cy_socket_create API function.
[in]addressAddress to be bound to the socket. Refer cy_socket_ip_address_t for IP address endienness.
[in]address_lengthLength of the cy_socket_sockaddr_t structure.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_TCPIP_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_NOMEM
CY_RSLT_MODULE_SECURE_SOCKETS_PROTOCOL_NOT_SUPPORTED

◆ cy_socket_listen()

cy_rslt_t cy_socket_listen ( cy_socket_t  handle,
int  backlog 
)

Listens for TCP/TLS socket connections and limits the queue of incoming connections.

If the socket has been configured with a connection request callback, the registered callback will be invoked when the new client connection request is received. Invoke the cy_socket_accept API function from the callback function to accept the client connection.

Parameters
[in]handleSocket handle returned by the cy_socket_create API function.
[in]backlogMaximum pending connections allowed.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_TCPIP_ERROR

◆ cy_socket_accept()

cy_rslt_t cy_socket_accept ( cy_socket_t  handle,
cy_socket_sockaddr_t address,
uint32_t *  address_length,
cy_socket_t socket 
)

Accepts a new TCP/TLS connection on a socket.

This is a blocking API function that returns when there is an incoming connection request from a client.

However, when the CY_SOCKET_SO_RCVTIMEO socket option is set on the listening socket (input socket handle param), this API function returns with a CY_RSLT_MODULE_SECURE_SOCKETS_TIMEOUT error if there is no connection request from a client within the timeout period.

CY_SOCKET_SO_RCVTIMEO can be set using the cy_socket_setsockopt API function.

Parameters
[in]handleSocket handle that has been created with cy_socket_create, bound to a local address with cy_socket_bind, and is listening for connections after a call to cy_socket_listen. This is the server-side socket that is reused to establish connections across clients.
[out]addressAddress of the peer socket in the cy_socket_sockaddr_t structure. Refer cy_socket_ip_address_t for IP address endienness.
[out]address_lengthContains the actual size of the peer socket address.
[out]socketSocket handle for the accepted connection with a client. This is the socket that should be used for further communication over a new client connection.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_TLS_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TIMEOUT
CY_RSLT_MODULE_SECURE_SOCKETS_NOMEM
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_NOT_LISTENING

◆ cy_socket_send()

cy_rslt_t cy_socket_send ( cy_socket_t  handle,
const void *  buffer,
uint32_t  length,
int  flags,
uint32_t *  bytes_sent 
)

Sends data over a connected TCP/TLS socket.

Note
Ensure that the cy_socket_disconnect API function is called when this API function fails with the CY_RSLT_MODULE_SECURE_SOCKETS_CLOSED error. lwIP doesn't allow the socket to be reused after disconnection. Therefore, the caller should call cy_socket_disconnect and cy_socket_delete API functions to delete the closed socket. This is applicable if Secure Sockets Library is built for lwIP network stack.
Parameters
[in]handleSocket handle returned by either the cy_socket_create API function for client sockets, or by the cy_socket_accept API function for accepted sockets.
[in]bufferBuffer containing the data to be sent.
[in]lengthLength of the data to be sent.
[in]flagsFlags to indicate the send options: CY_SOCKET_FLAGS_NONE and CY_SOCKET_FLAGS_MORE
[out]bytes_sentNumber of bytes sent.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. On success, it also returns the number of bytes sent. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_TLS_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TCPIP_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TIMEOUT
CY_RSLT_MODULE_SECURE_SOCKETS_NOT_CONNECTED
CY_RSLT_MODULE_SECURE_SOCKETS_CLOSED
CY_RSLT_MODULE_SECURE_SOCKETS_WOULDBLOCK

◆ cy_socket_sendto()

cy_rslt_t cy_socket_sendto ( cy_socket_t  handle,
const void *  buffer,
uint32_t  length,
int  flags,
const cy_socket_sockaddr_t dest_addr,
uint32_t  address_length,
uint32_t *  bytes_sent 
)

Sends a UDP datagram over a specified socket.

Note
If an ARP entry for the specified destination address is not present in the ARP cache, this function sends an ARP request and waits for ARP_WAIT_TIME_IN_MSEC time for MAC address resolution. If the MAC address is not resolved within the timeout, this function returns the error code CY_RSLT_MODULE_SECURE_SOCKETS_ARP_TIMEOUT. Upon receiving this error, the caller can retry this API again after a brief delay.
Parameters
[in]handleSocket handle returned by the cy_socket_create API function for UDP sockets.
[in]bufferBuffer containing the data to be sent.
[in]lengthLength of the data to be sent.
[in]flagsFlags to indicate send options. Currently, this argument is not used; this is reserved for the future.
[in]dest_addrPointer to the cy_socket_sockaddr_t structure that contains the destination address to send the data to. Refer cy_socket_ip_address_t for IP address endienness.
[in]address_lengthLength of the cy_socket_sockaddr_t structure.
[out]bytes_sentNumber of bytes sent.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. On success, it also returns the number of bytes sent. Important error code related to this API function is:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_NETIF_DOES_NOT_EXIST
CY_RSLT_MODULE_SECURE_SOCKETS_ARP_TIMEOUT
CY_RSLT_MODULE_SECURE_SOCKETS_ERROR_ROUTING

◆ cy_socket_recv()

cy_rslt_t cy_socket_recv ( cy_socket_t  handle,
void *  buffer,
uint32_t  length,
int  flags,
uint32_t *  bytes_received 
)

Receives the data from a connected TCP/TLS socket.

Note
Ensure that the cy_socket_disconnect API function is called when this API function fails with the CY_RSLT_MODULE_SECURE_SOCKETS_CLOSED error. lwIP doesn't allow the socket to be reused after disconnection. Therefore, the caller should call cy_socket_disconnect and cy_socket_delete API functions to delete the closed socket. This is applicable if Secure Sockets Library is built for lwIP network stack.
Parameters
[in]handleSocket handle returned by either the cy_socket_create API function for client sockets, or by cy_socket_accept API function for accepted sockets.
[out]bufferBuffer into which received data will be placed.
[in]lengthSize of the data buffer.
[in]flagsNot currently used. Should be set to CY_SOCKET_FLAGS_NONE.
[out]bytes_receivedNumber of bytes received.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. On success, it also returns number of bytes received. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_TLS_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TCPIP_ERROR
CY_RSLT_MODULE_SECURE_SOCKETS_TIMEOUT
CY_RSLT_MODULE_SECURE_SOCKETS_CLOSED
CY_RSLT_MODULE_SECURE_SOCKETS_WOULDBLOCK

◆ cy_socket_recvfrom()

cy_rslt_t cy_socket_recvfrom ( cy_socket_t  handle,
void *  buffer,
uint32_t  length,
int  flags,
cy_socket_sockaddr_t src_addr,
uint32_t *  src_addr_length,
uint32_t *  bytes_received 
)

Receives a UDP datagram for the specified socket.

Note
  1. If the datagram is larger than the supplied buffer, excess bytes in the datagram is discarded.
  2. To receive data from a specific source address, the caller should set CY_SOCKET_FLAGS_RECVFROM_SRC_FILTER flag in the 'flags' parameter, and assign the source address through the 'src_addr' parameter. If CY_SOCKET_FLAGS_RECVFROM_SRC_FILTER flag is set and src_addr is NULL, this function returns with the error code CY_RSLT_MODULE_SECURE_SOCKETS_BADARG.
Parameters
[in]handleSocket handle returned by either the cy_socket_create API function for client sockets, or by cy_socket_accept API function for accepted sockets.
[out]bufferBuffer into which the received data will be placed.
[in]lengthSize of the data buffer.
[in]flagsFlags to control the datagram to be received. Refer CY_SOCKET_FLAGS_RECVFROM_NONE and CY_SOCKET_FLAGS_RECVFROM_SRC_FILTER.
[in,out]src_addrPointer to the cy_socket_sockaddr_t structure to store the sender's address. If passed as NULL, the sender's address is not returned to the caller. If the CY_SOCKET_FLAGS_RECVFROM_SRC_FILTER flag is set, it contains the source address from which the datagram to be received. Refer cy_socket_ip_address_t for IP address endienness.
[in]src_addr_lengthPointer containing source address length. Currently, this argument is not used; this is reserved for the future.
[out]bytes_receivedNumber of bytes received.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. On success, it returns the number of bytes received. If src_addr is not NULL it also returns sender address. Important error code related to this API function is:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG

◆ cy_socket_setsockopt()

cy_rslt_t cy_socket_setsockopt ( cy_socket_t  handle,
int  level,
int  optname,
const void *  optval,
uint32_t  optlen 
)

◆ cy_socket_getsockopt()

cy_rslt_t cy_socket_getsockopt ( cy_socket_t  handle,
int  level,
int  optname,
void *  optval,
uint32_t *  optlen 
)

Gets the value of a particular socket option.

Parameters
[in]handleHandle of the socket to get the option value for.
[in]levelLevel at which the option resides:
CY_SOCKET_SOL_SOCKET
CY_SOCKET_SOL_TCP
CY_SOCKET_SOL_TLS
[in]optnameSocket options:
CY_SOCKET_SO_RCVTIMEO
CY_SOCKET_SO_SNDTIMEO
CY_SOCKET_SO_NONBLOCK
CY_SOCKET_SO_NWRITE
CY_SOCKET_SO_TCP_USER_TIMEOUT
CY_SOCKET_SO_SERVER_NAME_INDICATION
CY_SOCKET_SO_TLS_AUTH_MODE
CY_SOCKET_SO_IP_TOS
[out]optvalBuffer containing the value of the option to get.
[in,out]optlenLength of the option value. It is a value-result argument; the caller provides the size of the buffer pointed to by optval, and is modified by this function on return to indicate the actual size of the value returned.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_OPTION
CY_RSLT_MODULE_SECURE_SOCKETS_PROTOCOL_NOT_SUPPORTED
CY_RSLT_MODULE_SECURE_SOCKETS_OPTION_NOT_SUPPORTED

◆ cy_socket_gethostbyname()

cy_rslt_t cy_socket_gethostbyname ( const char *  hostname,
cy_socket_ip_version_t  ip_ver,
cy_socket_ip_address_t addr 
)

Resolves a host name using Domain Name Service.

Parameters
[in]hostnameHostname to resolve. It should be a null-terminated string containing ASCII characters.
[in]ip_verIP version type cy_socket_ip_version_t for which the hostname has to be resolved.
[out]addrIP address of the specified host. Refer cy_socket_ip_address_t for IP address endienness.
Returns
On success it returns CY_RSLT_SUCCESS and the IP address of the specified host. Returns an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_BADARG
CY_RSLT_MODULE_SECURE_SOCKETS_HOST_NOT_FOUND

◆ cy_socket_poll()

cy_rslt_t cy_socket_poll ( cy_socket_t  handle,
uint32_t *  rwflags,
uint32_t  timeout 
)

Checks whether data is available on the socket.

Parameters
[in]handleSocket handle returned by either the cy_socket_create API function for client sockets, or by cy_socket_accept API function for accepted sockets.
[in,out]rwflagsOn input, the flags indicate whether the socket needs to be polled for read/write/read-write operation. On return, the flags are updated to indicate the status of the socket readiness for a read/write/read-write operation.
[in]timeoutMaximum amount of time in milliseconds to wait before returning. If timeout is zero, the function returns immediately. If timeout is CY_SOCKET_NEVER_TIMEOUT, the function waits indefinitely.
Returns
On success, it returns CY_RSLT_SUCCESS. The CY_SOCKET_POLL_READ flag is set in the rwflags parameter if data is available for read. The CY_SOCKET_POLL_WRITE flag is set if the socket is ready for write operations. Returns an error code on failure. Important error codes related to this API function are:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET
CY_RSLT_MODULE_SECURE_SOCKETS_NOT_CONNECTED

◆ cy_socket_shutdown()

cy_rslt_t cy_socket_shutdown ( cy_socket_t  handle,
int  how 
)

Shuts down the send and/or receive operation on the given TCP socket.

Note
This API is not applicable for UDP.
Parameters
[in]handleSocket handle.
[in]howSocket shutdown modes. Supported modes: CY_SOCKET_SHUT_RD, CY_SOCKET_SHUT_WR, and CY_SOCKET_SHUT_RDWR.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error code related to this API function is:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET CY_RSLT_MODULE_SECURE_SOCKETS_BADARG

◆ cy_socket_delete()

cy_rslt_t cy_socket_delete ( cy_socket_t  handle)

Releases the resources allocated for the socket by the cy_socket_create function.

Parameters
[in]handleSocket handle returned by the cy_socket_create API function.
Returns
CY_RSLT_SUCCESS on success; an error code on failure. Important error code related to this API function is:
CY_RSLT_MODULE_SECURE_SOCKETS_INVALID_SOCKET