27 #ifndef _UCOMMON_SOCKET_H_ 28 #define _UCOMMON_SOCKET_H_ 30 #ifndef _UCOMMON_TIMERS_H_ 34 #ifndef _UCOMMON_LINKED_H_ 38 #ifndef _UCOMMON_STRING_H_ 42 #ifndef _UCOMMON_TYPEREF_H_ 51 #define SHUT_RDWR SD_BOTH 52 #define SHUT_WR SD_SEND 53 #define SHUT_RD SD_RECV 54 typedef uint16_t in_port_t;
55 typedef uint32_t in_addr_t;
58 #include <sys/socket.h> 60 #include <netinet/in.h> 64 #if defined(__ANDROID__) 65 typedef uint16_t in_port_t;
71 #ifndef IPTOS_LOWDELAY 72 #define IPTOS_LOWDELAY 0x10 73 #define IPTOS_THROUGHPUT 0x08 74 #define IPTOS_RELIABILITY 0x04 75 #define IPTOS_MINCOST 0x02 79 #define DEFAULT_FAMILY AF_UNSPEC 81 #define DEFAULT_FAMILY AF_INET 84 typedef struct sockaddr *sockaddr_t;
86 typedef struct sockaddr sockaddr_struct;
102 #if defined(AF_INET6) || defined(__CYGWIN__) 114 struct sockaddr_in6 ipv6;
116 struct sockaddr_in ipv4;
117 struct sockaddr address;
124 struct sockaddr_in ipv4;
125 struct sockaddr address;
129 struct sockaddr_storage
134 char sa_data[
sizeof(
struct sockaddr_in)];
144 #define IPPROTO_DCCP 23 151 #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12 152 #define DCCP_SOCKOPT_CCID 13 153 #define DCCP_SOCKOPT_TX_CCID 14 154 #define DCCP_SOCKOPT_RX_CCID 15 174 unsigned mask(
const char *cp)
const;
178 unsigned mask(
void)
const;
197 cidr(
const char *
string);
204 cidr(policy **policy,
const char *
string);
212 cidr(policy **policy,
const char *
string,
const char *name);
226 static const cidr *find(
const policy *policy,
const struct sockaddr *address);
235 static const cidr *container(
const policy *policy,
const struct sockaddr *address);
292 void set(
const char *string);
299 bool is_member(
const struct sockaddr *address)
const;
306 inline bool operator==(
const struct sockaddr *address)
const {
307 return is_member(address);
315 inline bool operator!=(
const struct sockaddr *address)
const {
316 return !is_member(address);
347 static struct addrinfo *query(
const char *host,
const char *service,
int type = SOCK_STREAM,
int protocol = 0);
354 static void release(
struct addrinfo *list);
380 address(
int family,
const char *
address,
int type = SOCK_STREAM,
int protocol = 0);
394 address(
int family,
const char *hostname,
const char *service = NULL);
402 address(
const char *host,
const char *service,
int type = SOCK_STREAM);
411 address(
const char *hostname, in_port_t port = 0);
416 address(
const in_addr& address, in_port_t port = 0);
421 address(
const in6_addr& address, in_port_t port = 0);
426 address(
const sockaddr& address) : list(NULL) {
446 address(
const address& reference);
452 address& operator=(
const address& rhs);
464 bool operator==(
const address& other)
const;
466 inline bool operator!=(
const address& other)
const {
467 return !(*
this==other);
470 inline bool equals(
const address& other)
const {
471 return *
this == other;
478 const struct sockaddr *
get(void)
const;
480 struct sockaddr *modify(
void);
482 inline const struct sockaddr *getAddr(
void)
const {
486 inline const struct sockaddr *operator()(
void)
const {
494 inline operator struct sockaddr *() {
503 const struct sockaddr *
get(
int family)
const;
505 struct sockaddr *modify(
int family);
507 inline const struct sockaddr *operator()(
int family)
const {
511 inline operator struct sockaddr_in *() {
512 return (
struct sockaddr_in *)modify(AF_INET);
516 inline operator struct sockaddr_in6 *() {
517 return (
struct sockaddr_in6 *)modify(AF_INET6);
525 int family(
void)
const;
540 return getPort(
get());
547 void setPort(in_port_t port);
553 address withPort(in_port_t port)
const;
559 struct sockaddr *find(
const struct sockaddr *
addr)
const;
597 size_t print(
char* dst,
size_t dst_sz,
bool port=
false,
bool force_brackets=
false)
const {
598 return print(
get(), dst, dst_sz, port, force_brackets);
605 inline operator bool()
const {
606 return list !=
nullptr;
609 inline bool is_valid()
const {
610 return list !=
nullptr;
613 inline bool isValid()
const {
614 return list !=
nullptr;
622 return list ==
nullptr;
634 inline bool isAny()
const {
644 void setAny(
int family = AF_UNSPEC);
652 return isLoopback(
get());
655 inline bool isLoopback()
const {
656 return isLoopback(
get());
665 void setLoopback(
int family = AF_UNSPEC);
678 void set(
const char *hostname,
const char *service = NULL,
int type = SOCK_STREAM);
686 void add(
const char *hostname,
const char *service = NULL,
int type = SOCK_STREAM);
695 void set(
int family,
const char *address,
int type = SOCK_STREAM,
int protocol = 0);
701 void add(sockaddr *address);
708 unsigned insert(
const struct addrinfo *address);
715 unsigned remove(
const struct addrinfo *address);
722 bool remove(
const struct sockaddr *address);
730 bool insert(
const struct sockaddr *address);
743 void set(
struct sockaddr *address);
750 void set(
const char *hostname, in_port_t service = 0);
756 static size_t getLength(
const struct sockaddr *address) {
764 inline static in_port_t
getPort(
const struct sockaddr *address) {
765 return Socket::port(address);
773 static void setPort(
struct sockaddr *address, in_port_t port);
780 static bool isAny(
const struct sockaddr *address);
786 static void setAny(
struct sockaddr *sa);
791 static sockaddr_storage any(
int family);
798 static bool isLoopback(
const struct sockaddr *address);
805 static void setLoopback(
struct sockaddr *sa);
810 static sockaddr_storage loopback(
int family);
817 static struct sockaddr *
dup(
struct sockaddr *address);
824 static struct sockaddr_in *ipv4(
struct sockaddr *address);
832 static struct sockaddr_in6 *ipv6(
struct sockaddr *address);
847 static size_t print(
const struct sockaddr *src,
char* dst,
size_t dst_sz,
bool port=
false,
bool ipv6_brackets=
false);
882 Socket(
int family,
int type,
int protocol = 0);
893 Socket(
const char *address,
const char *port,
int family = AF_UNSPEC,
int type = 0,
int protocol = 0);
909 static void cancel(socket_t socket);
919 inline int err(
void)
const {
928 bool is_pending(
unsigned value);
934 bool connected(
void)
const;
942 bool wait(timeout_t timeout = 0)
const;
959 static bool wait(socket_t socket, timeout_t timeout = 0);
967 bool waitSending(timeout_t timeout = 0)
const;
983 return broadcast(so, enable);
992 return keepalive(so, enable);
1001 return blocking(so, enable);
1010 return multicast(so, ttl);
1019 return loopback(so, enable);
1035 inline int ttl(uint8_t time) {
1036 return ttl(so, time);
1045 return sendsize(so, size);
1054 return sendwait(so, size);
1063 return recvsize(so, size);
1071 static int type(
const socket_t socket);
1079 static unsigned segsize(socket_t socket,
unsigned size = 0);
1087 static bool ccid(socket_t socket, uint8_t
id);
1103 return segsize(so, size);
1112 return ccid(so,
id);
1124 return tos(so, type);
1134 return priority(so, scheduling);
1141 ::shutdown(so, SHUT_RDWR);
1151 int connectto(
struct addrinfo *list);
1159 int disconnect(
void);
1166 int join(
const struct addrinfo *list,
const int ifindex = 0);
1173 int drop(
const struct addrinfo *list,
const int ifindex = 0);
1180 int wait(timeout_t timeout = Timer::inf);
1188 size_t peek(
void *data,
size_t number)
const;
1197 size_t readfrom(
void *data,
size_t number,
struct sockaddr_storage *address = NULL);
1206 size_t writeto(
const void *data,
size_t number,
const struct sockaddr *address = NULL);
1220 size_t readline(
char *data,
size_t size);
1227 size_t printf(
const char *format, ...) __PRINTF(2,3);
1240 size_t readline(
String& buffer);
1242 stringref_t readline(
size_t maxsize);
1255 static ssize_t readline(socket_t socket,
char *data,
size_t size, timeout_t timeout = Timer::inf);
1263 static ssize_t printf(socket_t socket,
const char *format, ...) __PRINTF(2,3);
1272 size_t writes(
const char *
string);
1278 operator bool()
const;
1284 bool operator!()
const;
1291 Socket& operator=(socket_t socket);
1297 inline operator socket_t()
const {
1315 static unsigned pending(socket_t socket);
1323 static int sendsize(socket_t socket,
unsigned size);
1331 static int sendwait(socket_t socket,
unsigned size);
1339 static int recvsize(socket_t socket,
unsigned size);
1349 static int connectto(socket_t socket,
struct addrinfo *list);
1356 static int disconnect(socket_t socket);
1364 static int drop(socket_t socket,
const struct addrinfo *list,
const int ifindex = 0);
1372 static int join(socket_t socket,
const struct addrinfo *list,
const int ifindex = 0);
1379 static int error(
const socket_t socket);
1387 static int multicast(socket_t socket,
unsigned ttl = 1);
1395 static int loopback(socket_t socket,
bool enable);
1403 static int blocking(socket_t socket,
bool enable);
1411 static int keepalive(socket_t socket,
bool enable);
1419 static int broadcast(socket_t socket,
bool enable);
1426 static int nodelay(socket_t socket);
1434 static int priority(socket_t socket,
int scheduling);
1442 static int tos(socket_t socket,
int type);
1450 static int ttl(socket_t socket, uint8_t time);
1456 static int family(socket_t socket);
1463 inline static int family(
const struct sockaddr_storage& address) {
1464 return ((
const struct sockaddr *)&address)->sa_family;
1473 return address.address.sa_family;
1485 static ssize_t recvfrom(socket_t socket,
void *buffer,
size_t size,
int flags = 0,
struct sockaddr_storage *address = NULL);
1496 static ssize_t sendto(socket_t socket,
const void *buffer,
size_t size,
int flags = 0,
const struct sockaddr *address = NULL);
1507 inline static ssize_t
replyto(socket_t socket,
const void *buffer,
size_t size,
int flags,
const struct sockaddr_storage *address) {
1508 return sendto(socket, buffer, size, flags, (
const struct sockaddr *)address);
1519 static int bindto(socket_t socket,
const char *address,
const char *service,
int protocol = 0);
1528 static int listento(socket_t socket,
const struct sockaddr *address,
int backlog = 5);
1536 static int bindto(socket_t socket,
const struct sockaddr *address);
1544 static socket_t acceptfrom(socket_t socket,
struct sockaddr_storage *address = NULL);
1553 static socket_t create(
int family,
int type,
int protocol);
1562 static socket_t create(
const struct addrinfo *address,
int type,
int protocol);
1573 static socket_t create(
const char *iface,
const char *service,
int family = AF_UNSPEC,
int type = 0,
int protocol = 0);
1586 static void release(socket_t socket);
1595 static char *hostname(
const struct sockaddr *address,
char *buffer,
size_t size);
1616 static socklen_t query(socket_t socket,
struct sockaddr_storage *address,
const char *hostname,
const char *service);
1623 static socklen_t len(
const struct sockaddr *address);
1632 static bool equal(
const struct sockaddr *address1,
const struct sockaddr *address2);
1640 static unsigned copy(
struct sockaddr *target,
const struct sockaddr *origin);
1648 static unsigned store(
struct sockaddr_storage *storage,
const struct sockaddr *address);
1656 static unsigned store(
struct sockaddr_internet *storage,
const struct sockaddr *address);
1665 static bool eq_host(
const struct sockaddr *address1,
const struct sockaddr *address2);
1674 inline static bool eq_from(
const struct sockaddr_storage *address1,
const struct sockaddr_storage *address2) {
1675 return equal((
const struct sockaddr *)address1, (
const struct sockaddr *)address2);
1686 return equal((
const struct sockaddr *)address1, (
const struct sockaddr *)address2);
1696 static bool eq_subnet(
const struct sockaddr *address1,
const struct sockaddr *address2);
1706 static int via(
struct sockaddr *address,
const struct sockaddr *target, socklen_t size = 0);
1715 static char *query(
const struct sockaddr *address,
char *buffer, socklen_t size);
1722 static in_port_t port(
const struct sockaddr *address);
1730 return port((
const struct sockaddr *)address);
1739 static unsigned keyindex(
const struct sockaddr *address,
unsigned size);
1747 static unsigned keyhost(
const struct sockaddr *address,
unsigned size);
1752 static void init(
void);
1759 static void query(
int family);
1767 static void v4mapping(
bool enable);
1773 static int error(
void);
1783 static bool is_null(
const char *
string);
1792 static bool is_numeric(
const char *
string);
1802 static int local(socket_t socket,
struct sockaddr_storage *address);
1812 static int remote(socket_t socket,
struct sockaddr_storage *address);
1835 ListenSocket(
const char *
address,
const char *service,
unsigned backlog = 5,
int family = AF_UNSPEC,
int type = 0,
int protocol = 0);
1847 static socket_t create(
const char *address,
const char *service,
unsigned backlog = 5,
int family = AF_UNSPEC,
int type = 0,
int protocol = 0);
1854 socket_t accept(
struct sockaddr_storage *address = NULL)
const;
1861 inline bool wait(timeout_t timeout = Timer::inf)
const {
1862 return Socket::wait(timeout);
1869 inline operator socket_t()
const {
1889 inline socket_t handle(
void)
const {
1933 const struct sockaddr *_getaddrinfo(
const struct addrinfo *addrinfo)
const;
1938 socket_t _getaddrsock(
const struct addrinfo *addrinfo)
const;
1973 inline operator const struct sockaddr *()
const {
1974 return _getaddrinfo(ptr);
1982 return _getaddrinfo(ptr);
1985 inline operator const struct sockaddr_in *()
const {
1986 return (
struct sockaddr_in *)_getaddrinfo(ptr);
1989 inline const struct sockaddr_in *in(
void)
const {
1990 return (
struct sockaddr_in *)_getaddrinfo(ptr);
1994 inline operator const struct sockaddr_in6 *()
const {
1995 return (
struct sockaddr_in6 *)_getaddrinfo(ptr);
1998 inline const struct sockaddr_in6 *in6(
void)
const {
1999 return (
struct sockaddr_in6 *)_getaddrinfo(ptr);
2007 return _getaddrsock(ptr);
2014 inline operator bool()
const {
2015 return ptr !=
nullptr;
2058 return _getaddrinfo(ptr);
2066 return ptr ==
nullptr;
2069 inline void next(
void) {
2070 ptr = _nextaddrinfo(ptr);
2090 return address.
get();
2100 inline bool eq(
const struct sockaddr *s1,
const struct sockaddr *s2) {
2101 return Socket::equal(s1, s2);
2111 inline bool eq(
const struct sockaddr_storage *s1,
const struct sockaddr_storage *s2) {
2112 return Socket::equal((
const struct sockaddr *)s1, (
const struct sockaddr *)s2);
2122 inline bool eq_host(
const struct sockaddr *s1,
const struct sockaddr *s2) {
2126 inline bool eq_subnet(
const struct sockaddr *s1,
const struct sockaddr *s2) {
2127 return Socket::eq_subnet(s1, s2);
2140 inline HostAddress() {
2141 memset(&storage, 0,
sizeof(storage));
2144 inline HostAddress(
const HostAddress&
copy) {
2145 memcpy(&storage, ©.storage,
sizeof(storage));
2152 inline HostAddress(
const in_addr *addr) {
2153 memset(&storage, 0,
sizeof(storage));
2154 memcpy(&storage, addr,
sizeof(
struct in_addr));
2158 inline HostAddress(
const in6_addr *addr) {
2159 memset(&storage, 0,
sizeof(storage));
2160 memcpy(&storage, addr,
sizeof(
struct in6_addr));
2172 inline socklen_t size() {
2173 return sizeof(storage);
2176 inline HostAddress& operator=(
const HostAddress& copy) {
2177 memcpy(&storage, ©.storage,
sizeof(storage));
2186 inline bool operator==(
const HostAddress& check)
const {
2187 return (memcmp(&check.storage, &storage,
sizeof(storage)) == 0);
2190 inline bool operator!=(
const HostAddress& check)
const {
2191 return (memcmp(&check.storage, &storage,
sizeof(storage)) != 0);
2195 return (memcmp(host, &storage,
sizeof(storage)) == 0);
2199 return (memcmp(host, &storage,
sizeof(storage)) != 0);
2206 struct sockaddr_storage storage;
2209 inline SockAddress() {
2210 memset(&storage, 0,
sizeof(storage));
2213 inline SockAddress(
const SockAddress&
copy) {
2214 memcpy(&storage, ©.storage,
sizeof(storage));
2217 inline SockAddress(
const struct sockaddr *
addr) {
2218 Socket::store(&storage, addr);
2221 inline SockAddress& operator=(
const SockAddress& copy) {
2222 memcpy(&storage, ©.storage,
sizeof(storage));
2226 inline SockAddress& operator=(
const struct sockaddr *addr) {
2227 Socket::store(&storage, addr);
2231 inline operator const struct sockaddr *()
const {
2232 return (
const struct sockaddr*)&storage;
2235 inline struct sockaddr *operator*() {
2236 return (
struct sockaddr *)&storage;
2239 inline const struct sockaddr *
get()
const {
2240 return (
const struct sockaddr *)&storage;
2243 inline socklen_t size() {
2244 return sizeof(storage);
2247 inline bool operator==(
const SockAddress& check)
const {
2248 return Socket::equal(
get(), check.get());
2251 inline bool operator!=(
const SockAddress& check)
const {
2252 return !Socket::equal(
get(), check.get());
2255 inline bool operator==(
const struct sockaddr *check)
const {
2256 return Socket::equal(
get(), check);
2259 inline bool operator!=(
const struct sockaddr *check)
const {
2260 return !Socket::equal(
get(), check);
2270 inline InetAddress() {
2271 memset(&storage, 0,
sizeof(storage));
2274 inline InetAddress(
const InetAddress&
copy) {
2275 memcpy(&storage, ©.storage,
sizeof(storage));
2278 inline InetAddress(
const struct sockaddr *
addr) {
2279 Socket::store(&storage, addr);
2282 inline InetAddress& operator=(
const InetAddress& copy) {
2283 memcpy(&storage, ©.storage,
sizeof(storage));
2287 inline InetAddress& operator=(
const struct sockaddr *addr) {
2288 Socket::store(&storage, addr);
2292 inline operator const struct sockaddr *()
const {
2293 return (
const struct sockaddr*)&storage;
2296 inline struct sockaddr *operator*() {
2297 return (
struct sockaddr *)&storage;
2300 inline const struct sockaddr *
get()
const {
2301 return (
const struct sockaddr *)&storage;
2304 inline socklen_t size() {
2305 return sizeof(storage);
2308 inline bool operator==(
const SockAddress& check)
const {
2309 return Socket::equal(
get(), check.get());
2312 inline bool operator!=(
const SockAddress& check)
const {
2313 return !Socket::equal(
get(), check.get());
2316 inline bool operator==(
const struct sockaddr *check)
const {
2317 return Socket::equal(
get(), check);
2320 inline bool operator!=(
const struct sockaddr *check)
const {
2321 return !Socket::equal(
get(), check);
int nodelay(void) const
Set nodelay option for tcp socket.
static bool eq_from(const struct sockaddr_storage *address1, const struct sockaddr_storage *address2)
Compare socket addresses.
int loopback(bool enable)
Set loopback to read multicast packets we broadcast.
address(const sockaddr &address)
Construct a socket address from a sockaddr object.
const struct sockaddr * get(void) const
Get the first socket address in our address list.
socket_t operator*() const
Get the socket descriptor by pointer reference.
LinkedObject policy
A convenience type for using a pointer to a linked list as a policy chain.
void shutdown(void)
Shutdown the socket communication channel.
A generic tcp server class.
unsigned getMask(void) const
Get the number of bits in the cidr bitmask.
static int family(const struct sockaddr_storage &address)
Get the address family of a socket address object.
T * dup(const T &object)
Convenience function to duplicate object pointer to heap.
T copy(const T &src)
Convenience function to copy objects.
unsigned pending(void) const
Get the number of bytes of data in the socket receive buffer.
A thread-safe atomic heap management system.
size_t getLength(void) const
Get the address size of the first address.
static ssize_t replyto(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_storage *address)
Send reply on socket.
static in_port_t port(const struct sockaddr_internet *address)
Get the service port of an inet socket.
A class to hold internet segment routing rules.
struct addrinfo * operator*() const
Return the full socket address list by pointer reference.
bool eq(const struct sockaddr_storage *s1, const struct sockaddr_storage *s2)
Compare two stored socket addresses to see if equal.
int type(void) const
Get the type of a socket.
int broadcast(bool enable)
Set socket for unicast mode broadcasts.
bool operator==(const struct sockaddr *address) const
Test if a given socket address falls within this cidr.
in_port_t getPort(void) const
Get the port of the first address .
A bound socket used to listen for inbound socket connections.
int recvsize(unsigned size)
Set the size of the socket receive buffer.
int getFamily(void) const
Get the address family of our cidr block object.
bool ccid(uint8_t id)
Set ccid of dccp socket.
A copy-on-write string class that operates by reference count.
int tos(int type)
Set the type of service field of outgoing packets.
T * init(T *memory)
Template function to initialize memory by invoking default constructor.
bool operator!() const
Test if we have no address list.
bool is_loopback() const
Test if the first socket address is ADDR_LOOPBACK: 127.0.0.1 or ::1.
A smart pointer template for iterating linked lists.
A generic socket address class.
int sendwait(unsigned size)
Set the size to wait before sending.
int getError(void) const
Get socket error code.
socket_t operator*() const
Get the socket descriptor of the listener by pointer reference.
An object that holds ipv4 or ipv6 binary encoded host addresses.
unsigned segsize(unsigned size)
Set segment size and get mtu of a socket.
struct addrinfo * getList(void) const
Get the full socket address list from the object.
const struct sockaddr * operator*() const
Return the full socket address list by pointer reference.
linked_pointer & operator=(Socket::address &list)
Assign our pointer from an address list.
linked_pointer & operator=(const struct addrinfo *list)
Assign our pointer from an address list.
A common string class and character string support functions.
static in_port_t getPort(const struct sockaddr *address)
Returns the port of the socket address.
static size_t getLength(const struct sockaddr *address)
Returns the size of the socket address according to the family.
size_t print(char *dst, size_t dst_sz, bool port=false, bool force_brackets=false) const
Print the first socket address as a human-readable string to the provided buffer and returns the prin...
int err(void) const
Get error code.
A generic socket base class.
An object that can hold a ipv4 or ipv6 socket address.
struct addrinfo * addrinfo(Socket::address &address)
A convenience function to convert a socket address list into an addrinfo.
Linked objects, lists, templates, and containers.
socket_t operator()(void) const
Get socket as expression operator.
int ttl(uint8_t time)
Set the time to live before packets expire.
Common namespace for all ucommon objects.
socket_t getsocket(void) const
Get the socket descriptor of the listener.
static int family(const struct sockaddr_internet &address)
Get the address family of an internet socket address object.
bool operator!=(const struct sockaddr *address) const
Test if a given socket address falls outside this cidr.
bool operator!() const
Test if we have no address list.
const char * getName(void) const
Get the saved name of our cidr.
bool is_any() const
Test if the first socket address is ADDR_ANY: 0.0.0.0 or ::0.
const struct sockaddr * operator->() const
Return member from typed object our pointer references.
int keepalive(bool enable)
Set socket for keepalive packets.
Common base class for all objects that can be formed into a linked list.
int priority(int scheduling)
Set packet priority, 0 to 6 unless privileged.
Helper class for linked_pointer template.
int blocking(bool enable)
Set socket blocking I/O mode.
bool eq_host(const struct sockaddr *s1, const struct sockaddr *s2)
Compare two host addresses to see if equal.
int multicast(unsigned ttl=1)
Set multicast mode and multicast broadcast range.
address(const addrinfo *address)
Construct a socket address from an addrinfo structure.
bool wait(timeout_t timeout=Timer::inf) const
Wait for a pending connection.
const struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
int sendsize(unsigned size)
Set the size of the socket send buffer.
static bool eq_inet(const struct sockaddr_internet *address1, const struct sockaddr_internet *address2)
Compare socket addresses.
Realtime timers and timer queues.