socket_types.hpp revision 0ee85db398be8ea33d67cc42f99a1468cd6c8180
10ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 20ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// detail/socket_types.hpp 30ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// ~~~~~~~~~~~~~~~~~~~~~~~ 40ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 50ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) 60ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 70ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// Distributed under the Boost Software License, Version 1.0. (See accompanying 80ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 90ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// 100ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 110ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#ifndef ASIO_DETAIL_SOCKET_TYPES_HPP 120ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#define ASIO_DETAIL_SOCKET_TYPES_HPP 130ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 140ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 150ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/config.hpp" 160ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 170ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/ioctl.h> 180ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/poll.h> 190ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/types.h> 200ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/stat.h> 210ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <fcntl.h> 220ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(__hpux) 230ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/time.h> 240ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 250ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if !defined(__hpux) || defined(__SELECT) 260ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/select.h> 270ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 280ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/socket.h> 290ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/uio.h> 300ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/un.h> 310ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <netinet/in.h> 320ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <netinet/tcp.h> 330ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <arpa/inet.h> 340ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <netdb.h> 350ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <net/if.h> 360ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <limits.h> 370ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(__sun) 380ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/filio.h> 390ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# include <sys/sockio.h> 400ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 410ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 420ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/push_options.hpp" 430ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 440ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffienamespace asio { 450ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffienamespace detail { 460ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 470ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef int socket_type; 480ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int invalid_socket = -1; 490ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int socket_error_retval = -1; 500ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int max_addr_v4_str_len = INET_ADDRSTRLEN; 510ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#if defined(INET6_ADDRSTRLEN) 520ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE; 530ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#else // defined(INET6_ADDRSTRLEN) 540ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int max_addr_v6_str_len = 256; 550ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#endif // defined(INET6_ADDRSTRLEN) 560ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef sockaddr socket_addr_type; 570ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef in_addr in4_addr_type; 580ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(__hpux) 590ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined. 600ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffiestruct in4_mreq_type 610ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie{ 620ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie struct in_addr imr_multiaddr; 630ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie struct in_addr imr_interface; 640ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie}; 650ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# else 660ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef ip_mreq in4_mreq_type; 670ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 680ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef sockaddr_in sockaddr_in4_type; 690ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef in6_addr in6_addr_type; 700ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef ipv6_mreq in6_mreq_type; 710ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef sockaddr_in6 sockaddr_in6_type; 720ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef sockaddr_storage sockaddr_storage_type; 730ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef sockaddr_un sockaddr_un_type; 740ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef addrinfo addrinfo_type; 750ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef ::linger linger_type; 760ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef int ioctl_arg_type; 770ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef uint32_t u_long_type; 780ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef uint16_t u_short_type; 790ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#if defined(ASIO_HAS_SSIZE_T) 800ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef ssize_t signed_size_type; 810ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#else // defined(ASIO_HAS_SSIZE_T) 820ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffietypedef int signed_size_type; 830ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#endif // defined(ASIO_HAS_SSIZE_T) 840ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF(c) ASIO_OS_DEF_##c 850ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AF_UNSPEC AF_UNSPEC 860ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AF_INET AF_INET 870ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AF_INET6 AF_INET6 880ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SOCK_STREAM SOCK_STREAM 890ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SOCK_DGRAM SOCK_DGRAM 900ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SOCK_RAW SOCK_RAW 910ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SOCK_SEQPACKET SOCK_SEQPACKET 920ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPPROTO_IP IPPROTO_IP 930ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPPROTO_IPV6 IPPROTO_IPV6 940ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPPROTO_TCP IPPROTO_TCP 950ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPPROTO_UDP IPPROTO_UDP 960ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPPROTO_ICMP IPPROTO_ICMP 970ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPPROTO_ICMPV6 IPPROTO_ICMPV6 980ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_FIONBIO FIONBIO 990ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_FIONREAD FIONREAD 1000ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_INADDR_ANY INADDR_ANY 1010ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_MSG_OOB MSG_OOB 1020ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_MSG_PEEK MSG_PEEK 1030ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_MSG_DONTROUTE MSG_DONTROUTE 1040ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_MSG_EOR MSG_EOR 1050ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SHUT_RD SHUT_RD 1060ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SHUT_WR SHUT_WR 1070ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SHUT_RDWR SHUT_RDWR 1080ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SOMAXCONN SOMAXCONN 1090ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SOL_SOCKET SOL_SOCKET 1100ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_BROADCAST SO_BROADCAST 1110ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_DEBUG SO_DEBUG 1120ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_DONTROUTE SO_DONTROUTE 1130ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_KEEPALIVE SO_KEEPALIVE 1140ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_LINGER SO_LINGER 1150ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_SNDBUF SO_SNDBUF 1160ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_RCVBUF SO_RCVBUF 1170ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_SNDLOWAT SO_SNDLOWAT 1180ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_RCVLOWAT SO_RCVLOWAT 1190ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_SO_REUSEADDR SO_REUSEADDR 1200ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_TCP_NODELAY TCP_NODELAY 1210ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IP_MULTICAST_IF IP_MULTICAST_IF 1220ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IP_MULTICAST_TTL IP_MULTICAST_TTL 1230ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IP_MULTICAST_LOOP IP_MULTICAST_LOOP 1240ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IP_ADD_MEMBERSHIP IP_ADD_MEMBERSHIP 1250ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IP_DROP_MEMBERSHIP IP_DROP_MEMBERSHIP 1260ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IP_TTL IP_TTL 1270ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPV6_UNICAST_HOPS IPV6_UNICAST_HOPS 1280ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPV6_MULTICAST_IF IPV6_MULTICAST_IF 1290ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPV6_MULTICAST_HOPS IPV6_MULTICAST_HOPS 1300ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPV6_MULTICAST_LOOP IPV6_MULTICAST_LOOP 1310ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPV6_JOIN_GROUP IPV6_JOIN_GROUP 1320ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_IPV6_LEAVE_GROUP IPV6_LEAVE_GROUP 1330ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_CANONNAME AI_CANONNAME 1340ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_PASSIVE AI_PASSIVE 1350ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_NUMERICHOST AI_NUMERICHOST 1360ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(AI_NUMERICSERV) 1370ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_NUMERICSERV AI_NUMERICSERV 1380ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# else 1390ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_NUMERICSERV 0 1400ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 1410ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// Note: QNX Neutrino 6.3 defines AI_V4MAPPED, AI_ALL and AI_ADDRCONFIG but 1420ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// does not implement them. Therefore they are specifically excluded here. 1430ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(AI_V4MAPPED) && !defined(__QNXNTO__) 1440ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_V4MAPPED AI_V4MAPPED 1450ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# else 1460ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_V4MAPPED 0 1470ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 1480ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(AI_ALL) && !defined(__QNXNTO__) 1490ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_ALL AI_ALL 1500ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# else 1510ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_ALL 0 1520ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 1530ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(AI_ADDRCONFIG) && !defined(__QNXNTO__) 1540ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_ADDRCONFIG AI_ADDRCONFIG 1550ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# else 1560ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# define ASIO_OS_DEF_AI_ADDRCONFIG 0 1570ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 1580ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# if defined(IOV_MAX) 1590ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int max_iov_len = IOV_MAX; 1600ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# else 1610ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie// POSIX platforms are not required to define IOV_MAX. 1620ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int max_iov_len = 16; 1630ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie# endif 1640ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int custom_socket_option_level = 0xA5100000; 1650ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int enable_connection_aborted_option = 1; 1660ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffieconst int always_fail_option = 2; 1670ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 1680ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie} // namespace detail 1690ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie} // namespace asio 1700ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 1710ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#include "asio/detail/pop_options.hpp" 1720ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie 1730ee85db398be8ea33d67cc42f99a1468cd6c8180François Gaffie#endif // ASIO_DETAIL_SOCKET_TYPES_HPP 174