otp_socket.h
Include dependency graph for otp_socket.h:
This graph shows which files directly or indirectly include otp_socket.h:
Enums
Functions
-
const struct Nif *otp_socket_nif_get_nif(const char *nifname)
-
void otp_socket_init(GlobalContext *global)
-
bool term_to_otp_socket(term socket_term, struct SocketResource **otp_socket, Context *ctx)
Get the resource object associated with a socket term.
- Parameters:
socket_term – the term with the socket
otp_socket – on output, the socket resource
ctx – the current context
- Returns:
true in case of success
-
bool term_is_otp_socket(term socket_term)
Determine if a term is a socket term.
- Parameters:
socket_term – the term to test
- Returns:
true if it is a term
-
ssize_t socket_send(struct SocketResource *socket, const uint8_t *buf, size_t len, term dest)
Send data to a socket (without blocking)
- Parameters:
socket – the socket resource
buf – buffer to send
len – number of bytes
dest – destination address or invalid term for sendto/send
- Returns:
the number of written bytes or a value from SocketErrors
-
ssize_t socket_recv(struct SocketResource *socket, uint8_t *buf, size_t len, int flags, term *from, Heap *heap)
Read data from a socket.
- Parameters:
socket – the socket resource
buf – buffer to store data
len – number of bytes
flags – flags passed to recvfrom
from – filled with origin address using recvfrom (can be NULL)
heap – heap to build the origin address term (can be NULL if from is NULL)
- Returns:
the number of read bytes or a value from SocketErrors
-
void otp_socket_lwip_enqueue(struct LWIPEvent *event)
Enqueue an event to be processed in task context.
This function must be implemented in otp_socket_platform.c. Platforms using lwIP implementation may have lwIP callbacks coming from ISR and in such case need to implement a queue mechanism to process them in task context. GlobalContext is not always available in lwIP callbacks so platforms using a queue need a global variable. If lwIP callbacks are not called from ISR, calling handler with the event is sufficient.
- Parameters:
event – the event to enqueue
-
struct LWIPEvent
- #include <otp_socket.h>
Collaboration diagram for LWIPEvent: