** More...
Data Structures | |
| struct | sockaddr |
| socket address struct More... | |
| struct | in_addr |
| socket address(net format) More... | |
| struct | sockaddr_in |
| socket address_in struct More... | |
| struct | in6_addr |
| socket address(IPV6 net format) More... | |
| struct | sockaddr_in6 |
| socket address_in6 struct More... | |
| struct | sockaddr_storage |
| struct | addrinfo |
| socket address_in6 info More... | |
| struct | _fd_set |
Macros | |
| #define | FD_SETSIZE 64 |
| MAX fd number is 64 in MXOS. More... | |
| #define | NBBY 8 |
| number of bits in a byte. More... | |
| #define | NFDBITS (sizeof(unsigned long) * NBBY) |
| bits per mask More... | |
| #define | FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= MC_FDSET_MASK(n)) |
| Add a fd to FD set. More... | |
| #define | FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~MC_FDSET_MASK(n)) |
| Remove fd from FD set. More... | |
| #define | FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & MC_FDSET_MASK(n)) |
| Check if the fd is set in FD set. More... | |
| #define | FD_ZERO(p) memset((p), 0, sizeof(*(p))) |
| Clear FD set. More... | |
Enumerations |
Functions | |
| int32_t | MX_WIFI_Socket_create (MX_WIFIObject_t *Obj, int32_t domain, int32_t type, int32_t protocol) |
| Create a socket. More... | |
| int32_t | MX_WIFI_Socket_setsockopt (MX_WIFIObject_t *Obj, int32_t sockfd, int32_t level, int32_t optname, const void *optvalue, int32_t optlen) |
| Set option for a socket. More... | |
| int32_t | MX_WIFI_Socket_getsockopt (MX_WIFIObject_t *Obj, int32_t sockfd, int32_t level, int32_t optname, void *optvalue, uint32_t *optlen) |
| Get option of a socket. More... | |
| int32_t | MX_WIFI_Socket_bind (MX_WIFIObject_t *Obj, int32_t sockfd, const struct sockaddr *addr, int32_t addrlen) |
| Bind a socket. More... | |
| int32_t | MX_WIFI_Socket_listen (MX_WIFIObject_t *Obj, int32_t sockfd, int32_t backlog) |
| Listen a socket. More... | |
| int32_t | MX_WIFI_Socket_accept (MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen) |
| Accept a socket. More... | |
| int32_t | MX_WIFI_Socket_connect (MX_WIFIObject_t *Obj, int32_t sockfd, const struct sockaddr *addr, int32_t addrlen) |
| Socket connect. More... | |
| int32_t | MX_WIFI_Socket_shutdown (MX_WIFIObject_t *Obj, int32_t sockfd, int32_t mode) |
| Socket shutdown. More... | |
| int32_t | MX_WIFI_Socket_close (MX_WIFIObject_t *Obj, int32_t sockfd) |
| Socket close. More... | |
| int32_t | MX_WIFI_Socket_send (MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags) |
| Socket send. More... | |
| int32_t | MX_WIFI_Socket_recv (MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags) |
| Socket recv. More... | |
| int32_t | MX_WIFI_Socket_sendto (MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags, struct sockaddr *toaddr, int32_t toaddrlen) |
| Socket sendto. More... | |
| int32_t | MX_WIFI_Socket_recvfrom (MX_WIFIObject_t *Obj, int32_t sockfd, uint8_t *buf, int32_t len, int32_t flags, struct sockaddr *fromaddr, uint32_t *fromaddrlen) |
| Socket recvfrom. More... | |
| int32_t | MX_WIFI_Socket_gethostbyname (MX_WIFIObject_t *Obj, struct sockaddr *addr, char *name) |
| Gethostbyname, only for IPv4 address. More... | |
| int32_t | MX_WIFI_Socket_ping (MX_WIFIObject_t *Obj, const char *hostname, int32_t count, int32_t delay, int32_t response[]) |
| Ping a host, only for IPv4 address. More... | |
| int32_t | MX_WIFI_Socket_getpeername (MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen) |
| socket getpeername. More... | |
| int32_t | MX_WIFI_Socket_getsockname (MX_WIFIObject_t *Obj, int32_t sockfd, struct sockaddr *addr, uint32_t *addrlen) |
| socket getsockname. More... | |
**
socket related API **
| #define FD_CLR | ( | n, | |
| p | |||
| ) | ((p)->fds_bits[(n)/NFDBITS] &= ~MC_FDSET_MASK(n)) |
| #define FD_ISSET | ( | n, | |
| p | |||
| ) | ((p)->fds_bits[(n)/NFDBITS] & MC_FDSET_MASK(n)) |
| #define FD_SET | ( | n, | |
| p | |||
| ) | ((p)->fds_bits[(n)/NFDBITS] |= MC_FDSET_MASK(n)) |
| #define FD_ZERO | ( | p | ) | memset((p), 0, sizeof(*(p))) |
| #define NFDBITS (sizeof(unsigned long) * NBBY) |
| enum IP_OPT_VAL |
| enum SOCK_OPT_VAL |
socket option value
| int32_t MX_WIFI_Socket_accept | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| struct sockaddr * | addr, | ||
| uint32_t * | addrlen | ||
| ) |
Accept a socket.
| Obj | pointer to module handle |
| sockfd | socket fd |
| addr | client address |
| addrlen | length of client address |
| Accepted | client socket fd, return < 0 if failed. |
| int32_t MX_WIFI_Socket_bind | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| const struct sockaddr * | addr, | ||
| int32_t | addrlen | ||
| ) |
Bind a socket.
| Obj | pointer to module handle |
| sockfd | socket fd |
| addr | socket address |
| addrlen | address length |
| Operation | Status. |
| int32_t MX_WIFI_Socket_close | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd | ||
| ) |
| int32_t MX_WIFI_Socket_connect | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| const struct sockaddr * | addr, | ||
| int32_t | addrlen | ||
| ) |
Socket connect.
| Obj | pointer to module handle |
| sockfd | socket fd |
| addr | client address |
| addrlen | length of client address |
| Operation | Status. |
| int32_t MX_WIFI_Socket_create | ( | MX_WIFIObject_t * | Obj, |
| int32_t | domain, | ||
| int32_t | type, | ||
| int32_t | protocol | ||
| ) |
Create a socket.
| Obj | pointer to module handle |
| domain | socket domain |
| type | socket type |
| protocol | socket protocol |
| Socket | file descriptor, return < 1 if failed. |
| int32_t MX_WIFI_Socket_gethostbyname | ( | MX_WIFIObject_t * | Obj, |
| struct sockaddr * | addr, | ||
| char * | name | ||
| ) |
Gethostbyname, only for IPv4 address.
| Obj | pointer to module handle |
| addr | address of the host |
| name | hostname |
| Operation | Status. |
| int32_t MX_WIFI_Socket_getpeername | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| struct sockaddr * | addr, | ||
| uint32_t * | addrlen | ||
| ) |
socket getpeername.
| Obj | pointer to module handle |
| sockfd | socket fd |
| addr | address buffer |
| addrlen | size of address buffer |
| get | address of peer socket, return < 0 if failed. |
| int32_t MX_WIFI_Socket_getsockname | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| struct sockaddr * | addr, | ||
| uint32_t * | addrlen | ||
| ) |
socket getsockname.
| Obj | pointer to module handle |
| sockfd | socket fd |
| addr | address buffer |
| addrlen | size of address buffer |
| get | address of local socket, return < 0 if failed. |
| int32_t MX_WIFI_Socket_getsockopt | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| int32_t | level, | ||
| int32_t | optname, | ||
| void * | optvalue, | ||
| uint32_t * | optlen | ||
| ) |
Get option of a socket.
| Obj | pointer to module handle |
| sockfd | socket fd |
| level | option level |
| optname | option to set |
| optvalue | buffer pointer of value of the option |
| optlen | buffer pointer of length of the option value |
| Operation | Status. |
| int32_t MX_WIFI_Socket_listen | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| int32_t | backlog | ||
| ) |
Listen a socket.
| Obj | pointer to module handle |
| sockfd | socket fd |
| backlog | max number to queued. |
| Operation | Status. |
| int32_t MX_WIFI_Socket_ping | ( | MX_WIFIObject_t * | Obj, |
| const char * | hostname, | ||
| int32_t | count, | ||
| int32_t | delay, | ||
| int32_t | response[] | ||
| ) |
Ping a host, only for IPv4 address.
| Obj | pointer to module handle |
| addr | hostname |
| count | ping max count |
| delay | ping delay in millisecond |
| response | response time array of ping result |
| Operation | Status. |
| int32_t MX_WIFI_Socket_recv | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| uint8_t * | buf, | ||
| int32_t | len, | ||
| int32_t | flags | ||
| ) |
Socket recv.
| Obj | pointer to module handle |
| sockfd | socket fd |
| buf | recv buffer |
| len | length of recv buffer |
| flags | zero for MXOS |
| Number | of bytes received, return < 0 if failed. |
| int32_t MX_WIFI_Socket_recvfrom | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| uint8_t * | buf, | ||
| int32_t | len, | ||
| int32_t | flags, | ||
| struct sockaddr * | fromaddr, | ||
| uint32_t * | fromaddrlen | ||
| ) |
Socket recvfrom.
| Obj | pointer to module handle |
| sockfd | socket fd |
| buf | recv buffer |
| len | length of recv buffer |
| fromaddr | address of the data source |
| fromaddrlen | length of address of the data source |
| flags | zero for MXOS |
| Number | of bytes received, return < 0 if failed. |
| int32_t MX_WIFI_Socket_send | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| uint8_t * | buf, | ||
| int32_t | len, | ||
| int32_t | flags | ||
| ) |
Socket send.
| Obj | pointer to module handle |
| sockfd | socket fd |
| buf | send data buffer |
| len | length of send data |
| flags | zero for MXOS |
| Number | of bytes sent, return < 0 if failed. |
| int32_t MX_WIFI_Socket_sendto | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| uint8_t * | buf, | ||
| int32_t | len, | ||
| int32_t | flags, | ||
| struct sockaddr * | toaddr, | ||
| int32_t | toaddrlen | ||
| ) |
Socket sendto.
| Obj | pointer to module handle |
| sockfd | socket fd |
| buf | send data buffer |
| len | length of send data |
| flags | zero for MXOS |
| toaddr | address to send |
| toaddrlen | length of address to send |
| Number | of bytes sent, return < 0 if failed. |
| int32_t MX_WIFI_Socket_setsockopt | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| int32_t | level, | ||
| int32_t | optname, | ||
| const void * | optvalue, | ||
| int32_t | optlen | ||
| ) |
Set option for a socket.
| Obj | pointer to module handle |
| sockfd | socket fd |
| level | option level |
| optname | option to set |
| optvalue | value buffer for the option |
| optlen | length of the option value |
| Operation | Status. |
| int32_t MX_WIFI_Socket_shutdown | ( | MX_WIFIObject_t * | Obj, |
| int32_t | sockfd, | ||
| int32_t | mode | ||
| ) |
Socket shutdown.
| Obj | pointer to module handle |
| sockfd | socket fd |
| mode | shutdown mode: 0 Stop receiving data for this socket; 1 Stop trying to transmit data from this socket 2 Stop all transmit from this socket |
| Operation | Status. |