Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
CellularNonIPSocket Class Reference

Socket implementation for cellular Non-IP data delivery(NIDD). More...

#include <CellularNonIPSocket.h>

Inheritance diagram for CellularNonIPSocket:
Socket

Public Member Functions

virtual ~CellularNonIPSocket ()
 Destroy the socket. More...
 
 CellularNonIPSocket ()
 Creates a socket. More...
 
virtual nsapi_error_t open (mbed::CellularContext *cellular_context)
 Opens a socket on the given cellular context. More...
 
virtual nsapi_error_t open (mbed::ControlPlane_netif *cp_netif)
 Opens a socket that will use the given control plane interface for data delivery. More...
 
virtual nsapi_error_t close ()
 Closes socket. More...
 
virtual nsapi_size_or_error_t send (const void *data, nsapi_size_t size)
 Send data over a control plane cellular context. More...
 
virtual nsapi_size_or_error_t recv (void *data, nsapi_size_t size)
 Receive data from a socket. More...
 
virtual void set_blocking (bool blocking)
 Set blocking or non-blocking mode of the socket. More...
 
virtual void set_timeout (int timeout)
 Set timeout on blocking socket operations. More...
 
virtual void sigio (mbed::Callback< void()> func)
 Register a callback on state change of the socket. More...
 
virtual nsapi_error_t connect (const SocketAddress &address)
 NOT APPLICABLE. More...
 
virtual Socketaccept (nsapi_error_t *error=NULL)
 NOT APPLICABLE. More...
 
virtual nsapi_error_t listen (int backlog=1)
 NOT APPLICABLE. More...
 
virtual nsapi_error_t setsockopt (int level, int optname, const void *optval, unsigned optlen)
 NOT APPLICABLE. More...
 
virtual nsapi_error_t getsockopt (int level, int optname, void *optval, unsigned *optlen)
 NOT APPLICABLE. More...
 
virtual nsapi_error_t getpeername (SocketAddress *address)
 NOT APPLICABLE. More...
 
virtual nsapi_size_or_error_t sendto (const SocketAddress &address, const void *data, nsapi_size_t size)
 NOT APPLICABLE. More...
 
virtual nsapi_size_or_error_t recvfrom (SocketAddress *address, void *data, nsapi_size_t size)
 NOT APPLICABLE. More...
 
virtual nsapi_error_t bind (const SocketAddress &address)
 NOT APPLICABLE. More...
 

Detailed Description

Socket implementation for cellular Non-IP data delivery(NIDD).

Relies on Control Plane CIoT EPS optimization feature, implemented in ControlPlane_netif class.

Definition at line 37 of file CellularNonIPSocket.h.

Constructor & Destructor Documentation

virtual ~CellularNonIPSocket ( )
virtual

Destroy the socket.

Note
Closes socket if it's still open.

Creates a socket.

Member Function Documentation

virtual Socket* accept ( nsapi_error_t error = NULL)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_error_t bind ( const SocketAddress address)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_error_t close ( )
virtual

Closes socket.

Returns
NSAPI_ERROR_OK on success NSAPI_ERROR_NO_SOCKET otherwise

Implements Socket.

virtual nsapi_error_t connect ( const SocketAddress address)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_error_t getpeername ( SocketAddress address)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_error_t getsockopt ( int  level,
int  optname,
void *  optval,
unsigned *  optlen 
)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_error_t listen ( int  backlog = 1)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_error_t open ( mbed::CellularContext cellular_context)
virtual

Opens a socket on the given cellular context.

Parameters
cellular_contextCellular PDP context over which this socket is sending and receiving data. The context has support for providing a control plane interface for data delivery.
Returns
NSAPI_ERROR_OK on success NSAPI_ERROR_PARAMETER otherwise
virtual nsapi_error_t open ( mbed::ControlPlane_netif cp_netif)
virtual

Opens a socket that will use the given control plane interface for data delivery.

Attaches the event as callback to the control plane interface.

Parameters
cp_netifControl plane interface for data delivery.
Returns
NSAPI_ERROR_OK on success NSAPI_ERROR_PARAMETER otherwise
virtual nsapi_size_or_error_t recv ( void *  data,
nsapi_size_t  size 
)
virtual

Receive data from a socket.

By default, recv blocks until some data is received. If socket is set to nonblocking or times out, NSAPI_ERROR_WOULD_BLOCK can be returned to indicate no data.

Parameters
dataPointer to buffer for received data.
sizeSize of the buffer in bytes.
Returns
Number of received bytes on success, negative error code on failure.

Implements Socket.

virtual nsapi_size_or_error_t recvfrom ( SocketAddress address,
void *  data,
nsapi_size_t  size 
)
virtual

NOT APPLICABLE.

Implements Socket.

virtual nsapi_size_or_error_t send ( const void *  data,
nsapi_size_t  size 
)
virtual

Send data over a control plane cellular context.

By default, send blocks until all data is sent. If socket is set to nonblocking or times out, a partial amount can be written. NSAPI_ERROR_WOULD_BLOCK is returned if no data was written.

Parameters
dataBuffer of data to be sent.
sizeSize of the buffer in bytes.
Returns
Number of sent bytes on success, negative error code on failure.

Implements Socket.

virtual nsapi_size_or_error_t sendto ( const SocketAddress address,
const void *  data,
nsapi_size_t  size 
)
virtual

NOT APPLICABLE.

Implements Socket.

virtual void set_blocking ( bool  blocking)
virtual

Set blocking or non-blocking mode of the socket.

Initially all sockets are in blocking mode. In non-blocking mode blocking operations such as send/recv/accept return NSAPI_ERROR_WOULD_BLOCK if they cannot continue.

set_blocking(false) is equivalent to set_timeout(0) set_blocking(true) is equivalent to set_timeout(-1)

Parameters
blockingtrue for blocking mode, false for non-blocking mode.

Implements Socket.

virtual void set_timeout ( int  timeout)
virtual

Set timeout on blocking socket operations.

Initially all sockets have unbounded timeouts. NSAPI_ERROR_WOULD_BLOCK is returned if a blocking operation takes longer than the specified timeout. A timeout of 0 removes the timeout from the socket. A negative value gives the socket an unbounded timeout.

set_timeout(0) is equivalent to set_blocking(false) set_timeout(-1) is equivalent to set_blocking(true)

Parameters
timeoutTimeout in milliseconds

Implements Socket.

virtual nsapi_error_t setsockopt ( int  level,
int  optname,
const void *  optval,
unsigned  optlen 
)
virtual

NOT APPLICABLE.

Implements Socket.

virtual void sigio ( mbed::Callback< void()>  func)
virtual

Register a callback on state change of the socket.

The specified callback is called on state changes, such as when the socket can receive/send/accept successfully and when an error occurs. The callback may also be called spuriously without reason.

The callback may be called in an interrupt context and should not perform expensive operations such as receive/send calls.

Note! This is not intended as a replacement for a poll or attach-like asynchronous API, but rather as a building block for constructing such functionality. The exact timing of the registered function is not guaranteed and susceptible to change.

Parameters
funcFunction to call on state change.

Implements Socket.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.