Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
socket.h File Reference

BSD Sockets compatible API definitions. More...

#include <sys/types.h>
#include <zephyr/types.h>
#include <net/net_ip.h>
#include <net/dns_resolve.h>
#include <net/socket_select.h>
#include <stdlib.h>
#include <syscalls/socket.h>

Go to the source code of this file.

Data Structures

struct  zsock_pollfd
 
struct  zsock_addrinfo
 
struct  ifreq
 

Macros

#define ZSOCK_POLLIN   1
 
#define ZSOCK_POLLPRI   2
 
#define ZSOCK_POLLOUT   4
 
#define ZSOCK_POLLERR   8
 
#define ZSOCK_POLLHUP   0x10
 
#define ZSOCK_POLLNVAL   0x20
 
#define ZSOCK_MSG_PEEK   0x02
 
#define ZSOCK_MSG_TRUNC   0x20
 
#define ZSOCK_MSG_DONTWAIT   0x40
 
#define ZSOCK_MSG_WAITALL   0x100
 
#define ZSOCK_SHUT_RD   0
 
#define ZSOCK_SHUT_WR   1
 
#define ZSOCK_SHUT_RDWR   2
 
#define SOL_TLS   282
 
#define TLS_SEC_TAG_LIST   1
 
#define TLS_HOSTNAME   2
 
#define TLS_CIPHERSUITE_LIST   3
 
#define TLS_CIPHERSUITE_USED   4
 
#define TLS_PEER_VERIFY   5
 
#define TLS_DTLS_ROLE   6
 
#define TLS_ALPN_LIST   7
 
#define TLS_DTLS_HANDSHAKE_TIMEOUT_MIN   8
 
#define TLS_DTLS_HANDSHAKE_TIMEOUT_MAX   9
 
#define TLS_PEER_VERIFY_NONE   0
 
#define TLS_PEER_VERIFY_OPTIONAL   1
 
#define TLS_PEER_VERIFY_REQUIRED   2
 
#define TLS_DTLS_ROLE_CLIENT   0
 
#define TLS_DTLS_ROLE_SERVER   1
 
#define AI_PASSIVE   0x1
 
#define AI_CANONNAME   0x2
 
#define AI_NUMERICHOST   0x4
 
#define AI_V4MAPPED   0x8
 
#define AI_ALL   0x10
 
#define AI_ADDRCONFIG   0x20
 
#define AI_NUMERICSERV   0x400
 
#define NI_NUMERICHOST   1
 
#define NI_NUMERICSERV   2
 
#define NI_NOFQDN   4
 
#define NI_NAMEREQD   8
 
#define NI_DGRAM   16
 
#define NI_MAXHOST   64
 
#define IFNAMSIZ   Z_DEVICE_MAX_NAME_LEN
 
#define SOL_SOCKET   1
 
#define SO_REUSEADDR   2
 
#define SO_TYPE   3
 
#define SO_ERROR   4
 
#define SO_RCVTIMEO   20
 
#define SO_SNDTIMEO   21
 
#define SO_BINDTODEVICE   25
 
#define SO_TIMESTAMPING   37
 
#define SO_PROTOCOL   38
 
#define TCP_NODELAY   1
 
#define IPV6_V6ONLY   26
 
#define SO_PRIORITY   12
 
#define SO_TXTIME   61
 
#define SCM_TXTIME   SO_TXTIME
 
#define SO_SOCKS5   60
 

Functions

voidzsock_get_context_object (int sock)
 Obtain a file descriptor's associated net context. More...
 
int zsock_socket (int family, int type, int proto)
 Create a network socket. More...
 
int zsock_socketpair (int family, int type, int proto, int *sv)
 Create an unnamed pair of connected sockets. More...
 
int zsock_close (int sock)
 Close a network socket. More...
 
int zsock_shutdown (int sock, int how)
 Shutdown socket send/receive operations. More...
 
int zsock_bind (int sock, const struct sockaddr *addr, socklen_t addrlen)
 Bind a socket to a local network address. More...
 
int zsock_connect (int sock, const struct sockaddr *addr, socklen_t addrlen)
 Connect a socket to a peer network address. More...
 
int zsock_listen (int sock, int backlog)
 Set up a STREAM socket to accept peer connections. More...
 
int zsock_accept (int sock, struct sockaddr *addr, socklen_t *addrlen)
 Accept a connection on listening socket. More...
 
ssize_t zsock_sendto (int sock, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
 Send data to an arbitrary network address. More...
 
static ssize_t zsock_send (int sock, const void *buf, size_t len, int flags)
 Send data to a connected peer. More...
 
ssize_t zsock_sendmsg (int sock, const struct msghdr *msg, int flags)
 Send data to an arbitrary network address. More...
 
ssize_t zsock_recvfrom (int sock, void *buf, size_t max_len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
 Receive data from an arbitrary network address. More...
 
static ssize_t zsock_recv (int sock, void *buf, size_t max_len, int flags)
 Receive data from a connected peer. More...
 
int zsock_fcntl (int sock, int cmd, int flags)
 Control blocking/non-blocking mode of a socket. More...
 
int zsock_poll (struct zsock_pollfd *fds, int nfds, int timeout)
 Efficiently poll multiple sockets for events. More...
 
int zsock_getsockopt (int sock, int level, int optname, void *optval, socklen_t *optlen)
 Get various socket options. More...
 
int zsock_setsockopt (int sock, int level, int optname, const void *optval, socklen_t optlen)
 Set various socket options. More...
 
int zsock_getsockname (int sock, struct sockaddr *addr, socklen_t *addrlen)
 Get socket name. More...
 
int zsock_gethostname (char *buf, size_t len)
 Get local host name. More...
 
static char * zsock_inet_ntop (sa_family_t family, const void *src, char *dst, size_t size)
 Convert network address from internal to numeric ASCII form. More...
 
int zsock_inet_pton (sa_family_t family, const char *src, void *dst)
 Convert network address from numeric ASCII form to internal representation. More...
 
int zsock_getaddrinfo (const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res)
 Resolve a domain name to one or more network addresses. More...
 
void zsock_freeaddrinfo (struct zsock_addrinfo *ai)
 Free results returned by zsock_getaddrinfo() More...
 
const char * zsock_gai_strerror (int errcode)
 Convert zsock_getaddrinfo() error code to textual message. More...
 
int zsock_getnameinfo (const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
 Resolve a network address to a domain name or ASCII address. More...
 

Detailed Description

BSD Sockets compatible API definitions.

An API for applications to use BSD Sockets like API.