Mistake on this page?
Report an issue in GitHub or email us
Data Structures | Macros | Enumerations | Functions
Socket

** 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...
 

Detailed Description

**

socket related API **

Macro Definition Documentation

#define FD_CLR (   n,
 
)    ((p)->fds_bits[(n)/NFDBITS] &= ~MC_FDSET_MASK(n))

Remove fd from FD set.

Definition at line 876 of file mx_wifi.h.

#define FD_ISSET (   n,
 
)    ((p)->fds_bits[(n)/NFDBITS] & MC_FDSET_MASK(n))

Check if the fd is set in FD set.

Definition at line 877 of file mx_wifi.h.

#define FD_SET (   n,
 
)    ((p)->fds_bits[(n)/NFDBITS] |= MC_FDSET_MASK(n))

Add a fd to FD set.

Definition at line 875 of file mx_wifi.h.

#define FD_SETSIZE   64

MAX fd number is 64 in MXOS.

Definition at line 862 of file mx_wifi.h.

#define FD_ZERO (   p)    memset((p), 0, sizeof(*(p)))

Clear FD set.

Definition at line 878 of file mx_wifi.h.

#define NBBY   8

number of bits in a byte.

Definition at line 865 of file mx_wifi.h.

#define NFDBITS   (sizeof(unsigned long) * NBBY)

bits per mask

Definition at line 866 of file mx_wifi.h.

Enumeration Type Documentation

enum IP_OPT_VAL

IP option types, level: IPPROTO_IP.

Enumerator
IP_ADD_MEMBERSHIP 

Join multicast group.

IP_DROP_MEMBERSHIP 

Leave multicast group.

Definition at line 884 of file mx_wifi.h.

socket option value

Enumerator
SO_DEBUG 

Unimplemented: turn on debugging info recording.

SO_ACCEPTCONN 

socket has had listen()

SO_REUSEADDR 

Allow local address reuse.

SO_KEEPALIVE 

keep connections alive

SO_DONTROUTE 

Just use interface addresses.

SO_BROADCAST 

Permit to send and to receive broadcast messages.

SO_USELOOPBACK 

Bypass hardware when possible.

SO_LINGER 

linger on close if data present

SO_OOBINLINE 

Leave received OOB data in line.

SO_REUSEPORT 

Allow local address & port reuse.

SO_BLOCKMODE 

set socket as block(optval=0)/non-block(optval=1) mode.

Default is block mode.

SO_SNDTIMEO 

Send timeout in block mode.

block for ever in default mode.

SO_RCVTIMEO 

Recv timeout in block mode.

block 1 second in default mode.

SO_ERROR 

Get socket error number.

SO_TYPE 

Get socket type.

SO_NO_CHECK 

Don't create UDP checksum.

Definition at line 838 of file mx_wifi.h.

Function Documentation

int32_t MX_WIFI_Socket_accept ( MX_WIFIObject_t Obj,
int32_t  sockfd,
struct sockaddr addr,
uint32_t *  addrlen 
)

Accept a socket.

Parameters
Objpointer to module handle
sockfdsocket fd
addrclient address
addrlenlength of client address
Return values
Acceptedclient 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.

Parameters
Objpointer to module handle
sockfdsocket fd
addrsocket address
addrlenaddress length
Return values
OperationStatus.
int32_t MX_WIFI_Socket_close ( MX_WIFIObject_t Obj,
int32_t  sockfd 
)

Socket close.

Parameters
Objpointer to module handle
sockfdsocket fd
Return values
OperationStatus.
int32_t MX_WIFI_Socket_connect ( MX_WIFIObject_t Obj,
int32_t  sockfd,
const struct sockaddr addr,
int32_t  addrlen 
)

Socket connect.

Parameters
Objpointer to module handle
sockfdsocket fd
addrclient address
addrlenlength of client address
Return values
OperationStatus.
int32_t MX_WIFI_Socket_create ( MX_WIFIObject_t Obj,
int32_t  domain,
int32_t  type,
int32_t  protocol 
)

Create a socket.

Parameters
Objpointer to module handle
domainsocket domain
typesocket type
protocolsocket protocol
Return values
Socketfile 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.

Parameters
Objpointer to module handle
addraddress of the host
namehostname
Return values
OperationStatus.
int32_t MX_WIFI_Socket_getpeername ( MX_WIFIObject_t Obj,
int32_t  sockfd,
struct sockaddr addr,
uint32_t *  addrlen 
)

socket getpeername.

Parameters
Objpointer to module handle
sockfdsocket fd
addraddress buffer
addrlensize of address buffer
Return values
getaddress 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.

Parameters
Objpointer to module handle
sockfdsocket fd
addraddress buffer
addrlensize of address buffer
Return values
getaddress 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.

Parameters
Objpointer to module handle
sockfdsocket fd
leveloption level
optnameoption to set
optvaluebuffer pointer of value of the option
optlenbuffer pointer of length of the option value
Return values
OperationStatus.
int32_t MX_WIFI_Socket_listen ( MX_WIFIObject_t Obj,
int32_t  sockfd,
int32_t  backlog 
)

Listen a socket.

Parameters
Objpointer to module handle
sockfdsocket fd
backlogmax number to queued.
Return values
OperationStatus.
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.

Parameters
Objpointer to module handle
addrhostname
countping max count
delayping delay in millisecond
responseresponse time array of ping result
Return values
OperationStatus.
int32_t MX_WIFI_Socket_recv ( MX_WIFIObject_t Obj,
int32_t  sockfd,
uint8_t *  buf,
int32_t  len,
int32_t  flags 
)

Socket recv.

Parameters
Objpointer to module handle
sockfdsocket fd
bufrecv buffer
lenlength of recv buffer
flagszero for MXOS
Return values
Numberof 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.

Parameters
Objpointer to module handle
sockfdsocket fd
bufrecv buffer
lenlength of recv buffer
fromaddraddress of the data source
fromaddrlenlength of address of the data source
flagszero for MXOS
Return values
Numberof 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.

Parameters
Objpointer to module handle
sockfdsocket fd
bufsend data buffer
lenlength of send data
flagszero for MXOS
Return values
Numberof 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.

Parameters
Objpointer to module handle
sockfdsocket fd
bufsend data buffer
lenlength of send data
flagszero for MXOS
toaddraddress to send
toaddrlenlength of address to send
Return values
Numberof 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.

Parameters
Objpointer to module handle
sockfdsocket fd
leveloption level
optnameoption to set
optvaluevalue buffer for the option
optlenlength of the option value
Return values
OperationStatus.
int32_t MX_WIFI_Socket_shutdown ( MX_WIFIObject_t Obj,
int32_t  sockfd,
int32_t  mode 
)

Socket shutdown.

Parameters
Objpointer to module handle
sockfdsocket fd
modeshutdown mode: 0 Stop receiving data for this socket; 1 Stop trying to transmit data from this socket 2 Stop all transmit from this socket
Return values
OperationStatus.
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.