TizenRT Libs&Environment
v2.0 M2
|
Provides APIs for BSD Socket. More...
![]() |
Files | |
file | socket.h |
Socket APIs. | |
file | netdb.h |
DNS client API. | |
file | inet.h |
inet API | |
Data Structures | |
struct | netent |
struct | protoent |
struct | servent |
struct | servent_data |
Macros | |
#define | EXTERN extern |
#define | h_addr h_addr_list[0] /* For backward compatibility */ |
#define | EXTERN extern |
#define | EXTERN extern |
#define | INET_ADDRSTRLEN 16 |
#define | INET6_ADDRSTRLEN 46 |
#define | HTONS(ns) |
#define | HTONL(nl) |
#define | NTOHS(hs) HTONS(hs) |
#define | NTOHL(hl) HTONL(hl) |
#define | EXTERN extern |
Functions | |
int | socket (int domain, int type, int protocol) |
creates an unbound socket in a communications domain. More... | |
int | bind (int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) |
assigns an address to an unnamed socket. More... | |
int | connect (int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) |
requests a connection to be made on a socket More... | |
int | listen (int sockfd, int backlog) |
listen for socket connections and limit the queue of incoming connections More... | |
int | accept (int sockfd, struct sockaddr *addr, socklen_t *addrlen) |
requests a connection to be made on a socket More... | |
ssize_t | send (int sockfd, FAR const void *buf, size_t len, int flags) |
send a message on a socket More... | |
ssize_t | sendto (int sockfd, FAR const void *buf, size_t len, int flags, FAR const struct sockaddr *to, socklen_t tolen) |
send a message on a socket More... | |
ssize_t | recv (int sockfd, FAR void *buf, size_t len, int flags) |
send a message on a socket More... | |
ssize_t | recvfrom (int sockfd, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, FAR socklen_t *fromlen) |
receive a message from a socket More... | |
int | shutdown (int sockfd, int how) |
shut down socket send and receive operations More... | |
int | setsockopt (int sockfd, int level, int option, FAR const void *value, socklen_t value_len) |
set the socket options More... | |
int | getsockopt (int sockfd, int level, int option, FAR void *value, FAR socklen_t *value_len) |
get the socket options More... | |
int | getsockname (int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) |
get the socket name More... | |
int | getpeername (int s, struct sockaddr *name, socklen_t *namelen) |
get the name of the peer socket More... | |
ssize_t | recvmsg (int sockfd, struct msghdr *msg, int flags) |
ssize_t | sendmsg (int sockfd, struct msghdr *msg, int flags) |
struct hostent * | gethostbyname (const char *name) |
gethostbyname is a function to get 32bit ip address from domain name or ip address string. More... | |
void | freeaddrinfo (struct addrinfo *ai) |
freeaddrinfo() frees the memory allocated by the getaddrinfo() function. More... | |
int | getaddrinfo (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) |
getaddrinfo() is a function that returns information on a particular host name (such as its IP address) and loads up a struct sockaddr. More... | |
int | getnameinfo (const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) |
getnameinfo() is a function that returns translated string from 32bit(ipv4)/128bit(ipv6) IP address. As lwip doesn't support rarp and relative functions it has restricted usage. More... | |
EXTERN FAR char * | ether_ntoa (FAR const struct ether_addr *addr) |
ether_ntoa() function converts the Ethernet host address addr given in network byte order to a string in standard hex-digits-and-colons notation. More... | |
uint32_t | ntohl (uint32_t nl) |
Convert the unsigned integer netlong from network byte order to host byte order. More... | |
uint16_t | ntohs (uint16_t ns) |
Convert the unsigned short integer netshort from network byte order to host byte order. More... | |
uint32_t | htonl (uint32_t hl) |
Convert the unsigned integer hostlong from host byte order to network byte order. More... | |
uint16_t | htons (uint16_t hs) |
Convert the unsigned short integer hostshort from host byte order to network byte order. More... | |
int | inet_aton (FAR const char *cp, FAR struct in_addr *inp) |
Convert the Internet host address from the IPv4 numbers-and-dots notation into binary form. More... | |
in_addr_t | inet_addr (FAR const char *cp) |
Convert the Internet host address from the IPv4 numbers-and-dots notation into binary data in network byte order. More... | |
FAR char * | inet_ntoa (struct in_addr in) |
Convert the Internet host address to a string in IPv4 dotted-decimal notation. More... | |
Variables | |
EXTERN int | h_errno |
Provides APIs for BSD Socket.
#define h_addr h_addr_list[0] /* For backward compatibility */ |
#define HTONL | ( | nl | ) |
#define HTONS | ( | ns | ) |
int accept | ( | int | sockfd, |
struct sockaddr * | addr, | ||
socklen_t * | addrlen | ||
) |
requests a connection to be made on a socket
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[in,out] | addr | null or pointer to a sockaddr structure where the address of the connecting socket will be returned |
[in,out] | addrlen | on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address. |
int bind | ( | int | sockfd, |
FAR const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
assigns an address to an unnamed socket.
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor of the socket to be bound. |
[in] | addr | pointer to a sockaddr structure containing the address to be bound to the socket |
[in] | addrlen | the length of the sockaddr structure |
int connect | ( | int | sockfd, |
FAR const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
requests a connection to be made on a socket
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[in] | addr | pointer to a sockaddr structure containing the peer address |
[in] | addrlen | the length of the sockaddr structure |
EXTERN FAR char* ether_ntoa | ( | FAR const struct ether_addr * | addr | ) |
ether_ntoa() function converts the Ethernet host address addr given in network byte order to a string in standard hex-digits-and-colons notation.
#include <netinet/ether.h>
[in] | addr | is the Ethernet host address addr given in network byte order |
void freeaddrinfo | ( | struct addrinfo * | ai | ) |
freeaddrinfo() frees the memory allocated by the getaddrinfo() function.
[in] | ai | is the head of the addrinfo list |
int getaddrinfo | ( | const char * | nodename, |
const char * | servname, | ||
const struct addrinfo * | hints, | ||
struct addrinfo ** | res | ||
) |
getaddrinfo() is a function that returns information on a particular host name (such as its IP address) and loads up a struct sockaddr.
[in] | nodename | can be among a domain name, ip address and NULL |
[in] | servname | can be a port number passed as string or a service name |
[in] | hints | can be either NULL or an addrinfo structure with the type of service requested |
[out] | res | is a return pointer that points to a new addrinfo structure |
struct hostent* gethostbyname | ( | const char * | name | ) |
gethostbyname is a function to get 32bit ip address from domain name or ip address string.
[in] | name | can be the string of ip address or domain name |
int getnameinfo | ( | const struct sockaddr * | sa, |
size_t | salen, | ||
char * | host, | ||
size_t | hostlen, | ||
char * | serv, | ||
size_t | servlen, | ||
int | flags | ||
) |
getnameinfo() is a function that returns translated string from 32bit(ipv4)/128bit(ipv6) IP address. As lwip doesn't support rarp and relative functions it has restricted usage.
[in] | sa | is an ip address structure pointer |
[in] | salen | contains the length of sa structure, it is used to figure out ipv4/v6 structure |
[out] | host | is the return buffer that contains string that is translated from 32bit(ipv4)/128bit(ipv6) address. |
[out] | hostlen | contains the length of host buffer length. |
[out] | serv | is the return buffer that contains port number string. |
[out] | servlen | contains the length of serv buffer length. |
[in] | flags | is the bit field flag, this function supports NI_NUMERICHOST, NI_NUMERICSERV only. |
int getpeername | ( | int | s, |
struct sockaddr * | name, | ||
socklen_t * | namelen | ||
) |
get the name of the peer socket
#include <sys/socket.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | s | the file descriptor associated with the socket. |
[in,out] | name | null or pointer to a sockaddr structure where the address of the peer socket will be returned |
[in,out] | namelen | on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address. |
int getsockname | ( | int | sockfd, |
FAR struct sockaddr * | addr, | ||
FAR socklen_t * | addrlen | ||
) |
get the socket name
#include <sys/socket.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[in,out] | addr | null or pointer to a sockaddr structure where the address of the local socket will be returned |
[in,out] | addrlen | on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address. |
int getsockopt | ( | int | sockfd, |
int | level, | ||
int | option, | ||
FAR void * | value, | ||
FAR socklen_t * | value_len | ||
) |
get the socket options
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor of the socket |
[in] | level | the protocol level at which the option resides |
[in] | option | a single option to be retrieved |
[out] | value | pointer to value of the option retrieved |
[out] | value_len | the length of the value retrieved |
uint32_t htonl | ( | uint32_t | hl | ) |
Convert the unsigned integer hostlong from host byte order to network byte order.
#include <arpa/inet.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | hl | hostlong |
uint16_t htons | ( | uint16_t | hs | ) |
Convert the unsigned short integer hostshort from host byte order to network byte order.
#include <arpa/inet.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | hs | hostshort |
in_addr_t inet_addr | ( | FAR const char * | cp | ) |
Convert the Internet host address from the IPv4 numbers-and-dots notation into binary data in network byte order.
#include <arpa/inet.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | cp | the Internet host address |
int inet_aton | ( | FAR const char * | cp, |
FAR struct in_addr * | inp | ||
) |
Convert the Internet host address from the IPv4 numbers-and-dots notation into binary form.
#include <arpa/inet.h>
[in] | cp | the Internet host address |
[in] | inp | structure that will store the converted value (IPv4 numbers-and-dots notation) |
FAR char* inet_ntoa | ( | struct in_addr | in | ) |
Convert the Internet host address to a string in IPv4 dotted-decimal notation.
#include <arpa/inet.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | in | the Internet host address in network byte order |
int listen | ( | int | sockfd, |
int | backlog | ||
) |
listen for socket connections and limit the queue of incoming connections
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[in] | backlog | the number of outstanding connections in the socket's listen queue |
uint32_t ntohl | ( | uint32_t | nl | ) |
Convert the unsigned integer netlong from network byte order to host byte order.
#include <arpa/inet.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | nl | netlong |
uint16_t ntohs | ( | uint16_t | ns | ) |
Convert the unsigned short integer netshort from network byte order to host byte order.
#include <arpa/inet.h>
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | ns | netshort |
ssize_t recv | ( | int | sockfd, |
FAR void * | buf, | ||
size_t | len, | ||
int | flags | ||
) |
send a message on a socket
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[out] | buf | Points to a buffer where the message should be stored |
[out] | len | the length in bytes of the buffer |
[in] | flags | the type of message reception. |
ssize_t recvfrom | ( | int | sockfd, |
FAR void * | buf, | ||
size_t | len, | ||
int | flags, | ||
FAR struct sockaddr * | from, | ||
FAR socklen_t * | fromlen | ||
) |
receive a message from a socket
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[out] | buf | Pointer to the buffer where the message should be stored. |
[out] | len | the length of the message in bytes. |
[in] | flags | the type of message reception |
[in,out] | from | A null pointer, or pointer to sockaddr structure in which the sending address is to be stored |
[in,out] | fromlen | null or the length of the sockaddr structure |
ssize_t recvmsg | ( | int | sockfd, |
struct msghdr * | msg, | ||
int | flags | ||
) |
ssize_t send | ( | int | sockfd, |
FAR const void * | buf, | ||
size_t | len, | ||
int | flags | ||
) |
send a message on a socket
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[in] | buf | Pointer to the buffer containing the message to send. |
[in] | len | the length of the message in bytes. |
[in] | flags | the type of message transmission |
ssize_t sendmsg | ( | int | sockfd, |
struct msghdr * | msg, | ||
int | flags | ||
) |
ssize_t sendto | ( | int | sockfd, |
FAR const void * | buf, | ||
size_t | len, | ||
int | flags, | ||
FAR const struct sockaddr * | to, | ||
socklen_t | tolen | ||
) |
send a message on a socket
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor associated with the socket. |
[in] | buf | Pointer to the buffer containing the message to send. |
[in] | len | the length of the message in bytes. |
[in] | flags | the type of message transmission |
[in] | to | pointer to a sockaddr structure containing the destination address |
[in] | tolen | the length of the sockaddr structure |
int setsockopt | ( | int | sockfd, |
int | level, | ||
int | option, | ||
FAR const void * | value, | ||
socklen_t | value_len | ||
) |
set the socket options
/**
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor of the socket |
[in] | level | the protocol level |
[in] | option | the option to be set for the socket |
[in] | value | pointer to value of the option |
[in] | value_len | the length of the value |
int shutdown | ( | int | sockfd, |
int | how | ||
) |
shut down socket send and receive operations
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | sockfd | the file descriptor of the socket |
[in] | how | the type of shutdown |
int socket | ( | int | domain, |
int | type, | ||
int | protocol | ||
) |
creates an unbound socket in a communications domain.
#include <sys/socket.h>
SYSTEM CALL API
POSIX API (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
[in] | domain | the communications domain in which a socket is to be created. |
[in] | type | the type of socket to be created |
[in] | protocol | the protocol to be used with the socket |