Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
Sockets BSD-Like API module. More...
Go to the source code of this file.
Functions | |
void | lwip_socket_init (void) |
Initialize this module. | |
static struct lwip_sock * | get_socket (int s) |
Map a externally used socket index to the internal socket representation. | |
static struct lwip_sock * | tryget_socket (int s) |
Same as get_socket but doesn't set errno. | |
static int | alloc_socket (struct netconn *newconn, int accepted) |
Allocate a new socket for a given netconn. | |
static void | free_socket (struct lwip_sock *sock, int is_tcp) |
Free a socket. | |
int | lwip_listen (int s, int backlog) |
Set a socket into listen mode. | |
int | lwip_sendto (int s, const void *data, size_t size, int flags, const struct sockaddr *to, socklen_t tolen) |
Variables | |
static struct lwip_sock | sockets [NUM_SOCKETS] |
The global array of available sockets. | |
static struct lwip_select_cb * | select_cb_list |
The global list of tasks waiting for select. | |
static volatile int | select_cb_ctr |
This counter is increased from lwip_select when the list is chagned and checked in event_callback to see if it has changed. | |
static const int | err_to_errno_table [] |
Table to quickly map an lwIP error (err_t) to a socket error by using -err as an index. |
Detailed Description
Sockets BSD-Like API module.
Definition in file lwip_sockets.c.
Function Documentation
static int alloc_socket | ( | struct netconn * | newconn, |
int | accepted | ||
) | [static] |
Allocate a new socket for a given netconn.
- Parameters:
-
newconn the netconn for which to allocate a socket accepted 1 if socket has been created by accept(), 0 if socket has been created by socket()
- Returns:
- the index of the new socket; -1 on error
Definition at line 243 of file lwip_sockets.c.
static void free_socket | ( | struct lwip_sock * | sock, |
int | is_tcp | ||
) | [static] |
Free a socket.
The socket's netconn must have been delete before!
- Parameters:
-
sock the socket to free is_tcp != 0 for TCP sockets, used to free lastdata
Definition at line 280 of file lwip_sockets.c.
static struct lwip_sock* get_socket | ( | int | s ) | [static, read] |
Map a externally used socket index to the internal socket representation.
- Parameters:
-
s externally used socket index
- Returns:
- struct lwip_sock for the socket or NULL if not found
Definition at line 195 of file lwip_sockets.c.
int lwip_listen | ( | int | s, |
int | backlog | ||
) |
Set a socket into listen mode.
The socket may not have been used for another connection previously.
- Parameters:
-
s the socket to set to listening mode backlog (ATTENTION: needs TCP_LISTEN_BACKLOG=1)
- Returns:
- 0 on success, non-zero on failure
Definition at line 521 of file lwip_sockets.c.
int lwip_sendto | ( | int | s, |
const void * | data, | ||
size_t | size, | ||
int | flags, | ||
const struct sockaddr * | to, | ||
socklen_t | tolen | ||
) |
Go through the readset and writeset lists and see which socket of the sockets set in the sets has events. On return, readset, writeset and exceptset have the sockets enabled that had events.
exceptset is not used for now!!!
- Parameters:
-
maxfdp1 the highest socket index in the sets readset_in,: set of sockets to check for read events writeset_in,: set of sockets to check for write events exceptset_in,: set of sockets to check for error events readset_out,: set of sockets that had read events writeset_out,: set of sockets that had write events exceptset_out,: set os sockets that had error events
- Returns:
- number of sockets that had events (read/write/exception) (>= 0)
Processing exceptset is not yet implemented.
Callback registered in the netconn layer for each socket-netconn. Processes recvevent (data available) and wakes up tasks waiting for select.
Unimplemented: Close one end of a full-duplex connection. Currently, the full connection is closed.
A minimal implementation of fcntl. Currently only the commands F_GETFL and F_SETFL are implemented. Only the flag O_NONBLOCK is implemented.
Definition at line 788 of file lwip_sockets.c.
void lwip_socket_init | ( | void | ) |
Initialize this module.
This function has to be called before any other functions in this module!
Definition at line 184 of file lwip_sockets.c.
static struct lwip_sock* tryget_socket | ( | int | s ) | [static, read] |
Same as get_socket but doesn't set errno.
- Parameters:
-
s externally used socket index
- Returns:
- struct lwip_sock for the socket or NULL if not found
Definition at line 223 of file lwip_sockets.c.
Variable Documentation
const int err_to_errno_table[] [static] |
{ 0, ENOMEM, ENOBUFS, EWOULDBLOCK, EHOSTUNREACH, EINPROGRESS, EINVAL, EWOULDBLOCK, EADDRINUSE, EALREADY, ECONNABORTED, ECONNRESET, ENOTCONN, ENOTCONN, EIO, -1, }
Table to quickly map an lwIP error (err_t) to a socket error by using -err as an index.
Definition at line 135 of file lwip_sockets.c.
volatile int select_cb_ctr [static] |
This counter is increased from lwip_select when the list is chagned and checked in event_callback to see if it has changed.
Definition at line 131 of file lwip_sockets.c.
struct lwip_select_cb* select_cb_list [static] |
The global list of tasks waiting for select.
Definition at line 128 of file lwip_sockets.c.
struct lwip_sock sockets[NUM_SOCKETS] [static] |
The global array of available sockets.
Definition at line 126 of file lwip_sockets.c.
Generated on Tue Jul 12 2022 12:29:01 by
