UCommon
|
00001 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks. 00002 // Copyright (C) 2015 Cherokees of Idaho. 00003 // 00004 // This file is part of GNU uCommon C++. 00005 // 00006 // GNU uCommon C++ is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published 00008 // by the Free Software Foundation, either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // GNU uCommon C++ is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>. 00018 00027 #ifndef _UCOMMON_SOCKET_H_ 00028 #define _UCOMMON_SOCKET_H_ 00029 00030 #ifndef _UCOMMON_TIMERS_H_ 00031 #include <ucommon/timers.h> 00032 #endif 00033 00034 #ifndef _UCOMMON_LINKED_H_ 00035 #include <ucommon/linked.h> 00036 #endif 00037 00038 #ifndef _UCOMMON_STRING_H_ 00039 #include <ucommon/string.h> 00040 #endif 00041 00042 extern "C" { 00043 struct addrinfo; 00044 } 00045 00046 #ifdef _MSWINDOWS_ 00047 #define SHUT_RDWR SD_BOTH 00048 #define SHUT_WR SD_SEND 00049 #define SHUT_RD SD_RECV 00050 typedef uint16_t in_port_t; 00051 typedef uint32_t in_addr_t; 00052 #else 00053 #include <unistd.h> 00054 #include <sys/socket.h> 00055 #include <net/if.h> 00056 #include <netinet/in.h> 00057 #include <netdb.h> 00058 #endif 00059 00060 #if defined(__ANDROID__) 00061 typedef uint16_t in_port_t; 00062 #endif 00063 00064 #include <errno.h> 00065 #include <stdio.h> 00066 00067 #ifndef IPTOS_LOWDELAY 00068 #define IPTOS_LOWDELAY 0x10 00069 #define IPTOS_THROUGHPUT 0x08 00070 #define IPTOS_RELIABILITY 0x04 00071 #define IPTOS_MINCOST 0x02 00072 #endif 00073 00074 #ifdef AF_UNSPEC 00075 #define DEFAULT_FAMILY AF_UNSPEC 00076 #else 00077 #define DEFAULT_FAMILY AF_INET 00078 #endif 00079 00080 struct sockaddr_internet; 00081 00082 typedef struct sockaddr *sockaddr_t; 00083 00084 typedef struct sockaddr sockaddr_struct; // older gcc needs...? 00085 00089 typedef struct hostaddr_internet 00090 { 00091 union 00092 { 00093 struct in_addr ipv4; 00094 #ifdef AF_INET6 00095 struct in6_addr ipv6; 00096 #endif 00097 }; 00098 } inethostaddr_t; 00099 00100 #if defined(AF_INET6) || defined(__CYGWIN__) 00101 00108 typedef struct sockaddr_internet 00109 { 00110 union { 00111 #ifdef AF_INET6 00112 struct sockaddr_in6 ipv6; 00113 #endif 00114 struct sockaddr_in ipv4; 00115 struct sockaddr address; 00116 }; 00117 } inetsockaddr_t; 00118 #else 00119 typedef struct sockaddr_internet 00120 { 00121 union { 00122 struct sockaddr_in ipv4; 00123 struct sockaddr address; 00124 }; 00125 } inetsockaddr_t; 00126 00127 struct sockaddr_storage 00128 { 00129 #ifdef AF_UNIX 00130 char sa_data[128]; 00131 #else 00132 char sa_data[sizeof(struct sockaddr_in)]; 00133 #endif 00134 }; 00135 #endif 00136 00137 #ifndef SOCK_DCCP 00138 #define SOCK_DCCP 6 00139 #endif 00140 00141 #ifndef IPPROTO_DCCP 00142 #define IPPROTO_DCCP 23 00143 #endif 00144 00145 #ifndef SOL_DCCP 00146 #define SOL_DCCP 269 00147 #endif 00148 00149 #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12 00150 #define DCCP_SOCKOPT_CCID 13 00151 #define DCCP_SOCKOPT_TX_CCID 14 00152 #define DCCP_SOCKOPT_RX_CCID 15 00153 00154 namespace ucommon { 00155 00165 class __EXPORT cidr : public LinkedObject 00166 { 00167 protected: 00168 int Family; 00169 inethostaddr_t Netmask, Network; 00170 char Name[16]; 00171 00172 unsigned mask(const char *cp) const; 00173 00174 inethostaddr_t broadcast(void) const; 00175 00176 unsigned mask(void) const; 00177 00178 public: 00182 typedef LinkedObject policy; 00183 00187 cidr(); 00188 00195 cidr(const char *string); 00196 00202 cidr(policy **policy, const char *string); 00203 00210 cidr(policy **policy, const char *string, const char *name); 00211 00216 cidr(const cidr& existing); 00217 00224 static const cidr *find(const policy *policy, const struct sockaddr *address); 00225 00233 static const cidr *container(const policy *policy, const struct sockaddr *address); 00234 00242 inline const char *getName(void) const 00243 {return Name;} 00244 00249 inline int getFamily(void) const 00250 {return Family;} 00251 00256 inline inethostaddr_t getNetwork(void) const 00257 {return Network;} 00258 00263 inline inethostaddr_t getNetmask(void) const 00264 {return Netmask;} 00265 00270 inline inethostaddr_t getBroadcast(void) const 00271 {return broadcast();} 00272 00277 inline unsigned getMask(void) const 00278 {return mask();} 00279 00284 void set(const char *string); 00285 00291 bool is_member(const struct sockaddr *address) const; 00292 00298 inline bool operator==(const struct sockaddr *address) const 00299 {return is_member(address);} 00300 00306 inline bool operator!=(const struct sockaddr *address) const 00307 {return !is_member(address);} 00308 }; 00309 00317 class __EXPORT Socket 00318 { 00319 protected: 00320 socket_t so; 00321 int ioerr; 00322 timeout_t iowait; 00323 00324 public: 00333 static struct addrinfo *query(const char *host, const char *service, int type = SOCK_STREAM, int protocol = 0); 00334 00340 static void release(struct addrinfo *list); 00341 00350 class __EXPORT address 00351 { 00352 protected: 00353 struct addrinfo *list; 00354 00355 public: 00366 address(int family, const char *address, int type = SOCK_STREAM, int protocol = 0); 00367 00380 address(int family, const char *hostname, const char *service = NULL); 00381 00388 address(const char *host, const char *service, int type = SOCK_STREAM); 00389 00397 address(const char *hostname, in_port_t port = 0); 00398 00402 address(const in_addr& address, in_port_t port = 0); 00403 00407 address(const in6_addr& address, in_port_t port = 0); 00408 00412 address(const sockaddr& address) : list(NULL) 00413 {insert(address);} 00414 00418 address(const addrinfo* address) : list(NULL) 00419 {insert(address);} 00420 00424 address(); 00425 00430 address(const address& reference); 00431 00436 address& operator=(const address& rhs); 00437 00441 ~address(); 00442 00448 bool operator==(const address& other) const; 00449 00450 inline bool operator!=(const address& other) const 00451 {return !(*this==other);} 00452 00453 inline bool equals(const address& other) const 00454 {return *this == other;} 00455 00460 struct sockaddr *get(void) const; 00461 00462 inline struct sockaddr *getAddr(void) const 00463 {return get();} 00464 00465 inline struct sockaddr *operator()(void) const 00466 {return get();} 00467 00472 inline operator struct sockaddr *() const 00473 {return get();} 00474 00480 struct sockaddr *get(int family) const; 00481 00482 inline struct sockaddr *operator()(int family) const 00483 {return get(family);} 00484 00485 inline operator struct sockaddr_in *() const 00486 {return (struct sockaddr_in *)get(AF_INET);} 00487 00488 #ifdef AF_INET6 00489 inline operator struct sockaddr_in6 *() const 00490 {return (struct sockaddr_in6 *)get(AF_INET6);} 00491 #endif 00492 00497 int family(void) const; 00498 00503 inline size_t getLength(void) const 00504 {return len(get());} 00505 00510 inline in_port_t getPort(void) const 00511 {return getPort(get());} 00512 00517 void setPort(in_port_t port); 00518 00523 address withPort(in_port_t port) const; 00524 00529 struct sockaddr *find(const struct sockaddr *addr) const; 00530 00535 inline struct addrinfo *getList(void) const 00536 {return list;} 00537 00542 inline operator struct addrinfo *() const 00543 {return list;} 00544 00549 inline struct addrinfo *operator*() const 00550 {return list;} 00551 00564 size_t print(char* dst, size_t dst_sz, bool port=false, bool force_brackets=false) const 00565 {return print(get(), dst, dst_sz, port, force_brackets);} 00566 00571 inline operator bool() const 00572 {return list != NULL;} 00573 00578 inline bool operator!() const 00579 {return list == NULL;} 00580 00586 inline bool isAny() const 00587 {return isAny(get());} 00588 00595 void setAny(int family = AF_UNSPEC); 00596 00602 inline bool isLoopback() const 00603 {return isLoopback(get());} 00604 00611 void setLoopback(int family = AF_UNSPEC); 00612 00616 void clear(void); 00617 00624 void set(const char *hostname, const char *service = NULL, int type = SOCK_STREAM); 00625 00632 void add(const char *hostname, const char *service = NULL, int type = SOCK_STREAM); 00633 00641 void set(int family, const char *address, int type = SOCK_STREAM, int protocol = 0); 00642 00647 void add(sockaddr *address); 00648 00654 unsigned insert(const struct addrinfo *address); 00655 00661 unsigned remove(const struct addrinfo *address); 00662 00668 bool remove(const struct sockaddr *address); 00669 00676 bool insert(const struct sockaddr *address); 00677 inline bool insert(const struct sockaddr& address) 00678 {return insert(&address);} 00679 00685 void copy(const struct addrinfo *address); 00686 00691 void set(struct sockaddr *address); 00692 00698 void set(const char *hostname, in_port_t service = 0); 00699 00704 static size_t getLength(const struct sockaddr *address) 00705 {return len(address);} 00706 00711 static in_port_t getPort(const struct sockaddr *address); 00712 00718 static void setPort(struct sockaddr *address, in_port_t port); 00719 00725 static bool isAny(const struct sockaddr *address); 00726 00731 static void setAny(struct sockaddr *sa); 00732 00736 static sockaddr_storage any(int family); 00737 00743 static bool isLoopback(const struct sockaddr *address); 00744 00750 static void setLoopback(struct sockaddr *sa); 00751 00755 static sockaddr_storage loopback(int family); 00756 00762 static struct sockaddr *dup(struct sockaddr *address); 00763 00769 static struct sockaddr_in *ipv4(struct sockaddr *address); 00770 00771 #ifdef AF_INET6 00772 00777 static struct sockaddr_in6 *ipv6(struct sockaddr *address); 00778 #endif 00779 00792 static size_t print(const struct sockaddr *src, char* dst, size_t dst_sz, bool port=false, bool ipv6_brackets=false); 00793 }; 00794 00795 friend class address; 00796 00800 Socket(); 00801 00806 Socket(const Socket& existing); 00807 00812 Socket(socket_t socket); 00813 00819 Socket(const struct addrinfo *address); 00820 00827 Socket(int family, int type, int protocol = 0); 00828 00838 Socket(const char *address, const char *port, int family = AF_UNSPEC, int type = 0, int protocol = 0); 00839 00843 virtual ~Socket(); 00844 00848 void cancel(void); 00849 00854 static void cancel(socket_t socket); 00855 00859 void release(void); 00860 00864 inline int err(void) const 00865 {return ioerr;} 00866 00872 bool is_pending(unsigned value); 00873 00878 bool connected(void) const; 00879 00886 bool wait(timeout_t timeout = 0) const; 00887 00892 inline int nodelay(void) const 00893 {return nodelay(so);} 00894 00902 static bool wait(socket_t socket, timeout_t timeout = 0); 00903 00910 bool waitSending(timeout_t timeout = 0) const; 00911 00916 inline unsigned pending(void) const 00917 {return pending(so);} 00918 00924 inline int broadcast(bool enable) 00925 {return broadcast(so, enable);} 00926 00932 inline int keepalive(bool enable) 00933 {return keepalive(so, enable);} 00934 00940 inline int blocking(bool enable) 00941 {return blocking(so, enable);} 00942 00948 inline int multicast(unsigned ttl = 1) 00949 {return multicast(so, ttl);} 00950 00956 inline int loopback(bool enable) 00957 {return loopback(so, enable);} 00958 00963 inline int getError(void) 00964 {return error(so);} 00965 00971 inline int ttl(unsigned char time) 00972 {return ttl(so, time);} 00973 00979 inline int sendsize(unsigned size) 00980 {return sendsize(so, size);} 00981 00987 inline int sendwait(unsigned size) 00988 {return sendwait(so, size);} 00989 00990 00996 inline int recvsize(unsigned size) 00997 {return recvsize(so, size);} 00998 01004 static int type(socket_t socket); 01005 01012 static unsigned segsize(socket_t socket, unsigned size = 0); 01013 01020 static bool ccid(socket_t socket, uint8_t id); 01021 01026 inline int type(void) 01027 {return type(so);} 01028 01034 inline unsigned segsize(unsigned size) 01035 {return segsize(so, size);} 01036 01042 inline bool ccid(uint8_t id) 01043 {return ccid(so, id);} 01044 01053 inline int tos(int type) 01054 {return tos(so, type);} 01055 01062 inline int priority(int scheduling) 01063 {return priority(so, scheduling);} 01064 01068 inline void shutdown(void) 01069 {::shutdown(so, SHUT_RDWR);} 01070 01078 int connectto(struct addrinfo *list); 01079 01086 int disconnect(void); 01087 01093 int join(const struct addrinfo *list, const int ifindex = 0); 01094 01100 int drop(const struct addrinfo *list, const int ifindex = 0); 01101 01107 int wait(timeout_t timeout = Timer::inf); 01108 01115 size_t peek(void *data, size_t number) const; 01116 01124 size_t readfrom(void *data, size_t number, struct sockaddr_storage *address = NULL); 01125 01133 size_t writeto(const void *data, size_t number, const struct sockaddr *address = NULL); 01134 01147 size_t readline(char *data, size_t size); 01148 01154 size_t printf(const char *format, ...) __PRINTF(2,3); 01155 01167 size_t readline(String& buffer); 01168 01180 static ssize_t readline(socket_t socket, char *data, size_t size, timeout_t timeout = Timer::inf); 01181 01188 static ssize_t printf(socket_t socket, const char *format, ...) __PRINTF(2,3); 01189 01197 size_t writes(const char *string); 01198 01203 operator bool(); 01204 01209 bool operator!() const; 01210 01216 Socket& operator=(socket_t socket); 01217 01222 inline operator socket_t() const 01223 {return so;} 01224 01229 inline socket_t operator*() const 01230 {return so;} 01231 01238 static unsigned pending(socket_t socket); 01239 01246 static int sendsize(socket_t socket, unsigned size); 01247 01254 static int sendwait(socket_t socket, unsigned size); 01255 01262 static int recvsize(socket_t socket, unsigned size); 01263 01272 static int connectto(socket_t socket, struct addrinfo *list); 01273 01279 static int disconnect(socket_t socket); 01280 01287 static int drop(socket_t socket, const struct addrinfo *list, const int ifindex = 0); 01288 01295 static int join(socket_t socket, const struct addrinfo *list, const int ifindex = 0); 01296 01302 static int error(socket_t socket); 01303 01310 static int multicast(socket_t socket, unsigned ttl = 1); 01311 01318 static int loopback(socket_t socket, bool enable); 01319 01326 static int blocking(socket_t socket, bool enable); 01327 01334 static int keepalive(socket_t socket, bool enable); 01335 01342 static int broadcast(socket_t socket, bool enable); 01343 01349 static int nodelay(socket_t socket); 01350 01357 static int priority(socket_t socket, int scheduling); 01358 01365 static int tos(socket_t socket, int type); 01366 01373 static int ttl(socket_t socket, unsigned char time); 01374 01379 static int family(socket_t socket); 01380 01386 inline static int family(const struct sockaddr_storage& address) 01387 {return ((const struct sockaddr *)&address)->sa_family;} 01388 01394 inline static int family(const struct sockaddr_internet& address) 01395 {return address.address.sa_family;} 01396 01406 static ssize_t recvfrom(socket_t socket, void *buffer, size_t size, int flags = 0, struct sockaddr_storage *address = NULL); 01407 01417 static ssize_t sendto(socket_t socket, const void *buffer, size_t size, int flags = 0, const struct sockaddr *address = NULL); 01418 01428 inline static ssize_t replyto(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_storage *address) 01429 {return sendto(socket, buffer, size, flags, (const struct sockaddr *)address);} 01430 01440 inline static ssize_t sendinet(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_internet *address) 01441 {return sendto(socket, buffer, size, flags, (const struct sockaddr *)address);} 01442 01452 static ssize_t recvinet(socket_t socket, void *buffer, size_t size, int flags = 0, struct sockaddr_internet *address = NULL); 01453 01462 static int bindto(socket_t socket, const char *address, const char *service, int protocol = 0); 01463 01471 static int listento(socket_t socket, const struct sockaddr *address, int backlog = 5); 01472 01479 static int bindto(socket_t socket, const struct sockaddr *address); 01480 01487 static socket_t acceptfrom(socket_t socket, struct sockaddr_storage *address = NULL); 01488 01496 static socket_t create(int family, int type, int protocol); 01497 01505 static socket_t create(const struct addrinfo *address, int type, int protocol); 01506 01516 static socket_t create(const char *iface, const char *service, int family = AF_UNSPEC, int type = 0, int protocol = 0); 01517 01523 static socket_t create(const Socket::address &address); 01524 01529 static void release(socket_t socket); 01530 01538 static char *hostname(const struct sockaddr *address, char *buffer, size_t size); 01539 01547 static struct addrinfo *hinting(socket_t socket, struct addrinfo *hint); 01548 01559 static socklen_t query(socket_t socket, struct sockaddr_storage *address, const char *hostname, const char *service); 01560 01566 static socklen_t len(const struct sockaddr *address); 01567 01575 static bool equal(const struct sockaddr *address1, const struct sockaddr *address2); 01576 01583 static unsigned copy(struct sockaddr *target, const struct sockaddr *origin); 01584 01591 inline static unsigned store(struct sockaddr_storage *storage, const struct sockaddr *address) 01592 {return copy((struct sockaddr*)storage, address);} 01593 01600 static unsigned store(struct sockaddr_internet *storage, const struct sockaddr *address); 01601 01609 static bool eq_host(const struct sockaddr *address1, const struct sockaddr *address2); 01610 01618 inline static bool eq_from(const struct sockaddr_storage *address1, const struct sockaddr_storage *address2) 01619 {return equal((const struct sockaddr *)address1, (const struct sockaddr *)address2);} 01620 01628 inline static bool eq_inet(const struct sockaddr_internet *address1, const struct sockaddr_internet *address2) 01629 {return equal((const struct sockaddr *)address1, (const struct sockaddr *)address2);} 01630 01638 static bool eq_subnet(const struct sockaddr *address1, const struct sockaddr *address2); 01639 01647 static int via(struct sockaddr *address, const struct sockaddr *destination); 01648 01656 static char *query(const struct sockaddr *address, char *buffer, socklen_t size); 01657 01663 static short service(const struct sockaddr *address); 01664 01670 inline static short service(const struct sockaddr_internet *address) 01671 {return service((const struct sockaddr *)address);} 01672 01679 static unsigned keyindex(const struct sockaddr *address, unsigned size); 01680 01687 static unsigned keyhost(const struct sockaddr *address, unsigned size); 01688 01692 static void init(void); 01693 01698 static void init(const char *program); 01699 01705 static void query(int family); 01706 01713 static void v4mapping(bool enable); 01714 01719 static int error(void); 01720 01729 static bool is_null(const char *string); 01730 01738 static bool is_numeric(const char *string); 01739 01748 static int local(socket_t socket, struct sockaddr_storage *address); 01749 01758 static int remote(socket_t socket, struct sockaddr_storage *address); 01759 }; 01760 01766 class __EXPORT ListenSocket : protected Socket 01767 { 01768 public: 01778 ListenSocket(const char *address, const char *service, unsigned backlog = 5, int family = AF_UNSPEC, int type = 0, int protocol = 0); 01779 01790 static socket_t create(const char *address, const char *service, unsigned backlog = 5, int family = AF_UNSPEC, int type = 0, int protocol = 0); 01791 01797 socket_t accept(struct sockaddr_storage *address = NULL) const; 01798 01804 inline bool wait(timeout_t timeout = Timer::inf) const 01805 {return Socket::wait(timeout);} 01806 01811 inline operator socket_t() const 01812 {return so;} 01813 01818 inline socket_t operator*() const 01819 {return so;} 01820 01825 inline socket_t getsocket(void) const 01826 {return so;} 01827 01828 inline socket_t handle(void) const 01829 {return so;} 01830 01831 }; 01832 01838 class __EXPORT TCPServer : public ListenSocket 01839 { 01840 public: 01848 TCPServer(const char *address, const char *service, unsigned backlog = 5); 01849 }; 01850 01854 __EXPORT struct addrinfo *_nextaddrinfo(struct addrinfo *addrinfo); 01855 01859 __EXPORT struct sockaddr *_getaddrinfo(struct addrinfo *addrinfo); 01860 01864 __EXPORT socket_t _getaddrsock(struct addrinfo *addrinfo); 01865 01871 template <> 01872 class linked_pointer<sockaddr_struct> 01873 { 01874 private: 01875 struct addrinfo *ptr; 01876 01877 public: 01878 inline linked_pointer(struct addrinfo *list) 01879 {ptr = list;} 01880 01881 inline linked_pointer() 01882 {ptr = NULL;} 01883 01884 inline linked_pointer(Socket::address& list) 01885 {ptr = list.getList();} 01886 01891 inline operator struct sockaddr *() const 01892 {return _getaddrinfo(ptr);} 01893 01898 inline struct sockaddr *operator*() const 01899 {return _getaddrinfo(ptr);} 01900 01901 inline operator struct sockaddr_in *() const 01902 {return (struct sockaddr_in *)_getaddrinfo(ptr);} 01903 01904 inline struct sockaddr_in *in(void) const 01905 {return (struct sockaddr_in *)_getaddrinfo(ptr);} 01906 01907 #ifdef AF_INET6 01908 inline operator struct sockaddr_in6 *() const 01909 {return (struct sockaddr_in6 *)_getaddrinfo(ptr);} 01910 01911 inline struct sockaddr_in6 *in6(void) const 01912 {return (struct sockaddr_in6 *)_getaddrinfo(ptr);} 01913 #endif 01914 01918 inline socket_t operator()(void) const 01919 {return _getaddrsock(ptr);} 01920 01925 inline operator bool() const 01926 {return ptr != NULL;} 01927 01932 inline void operator=(struct addrinfo *list) 01933 {ptr = list;} 01934 01939 inline void operator=(Socket::address& list) 01940 {ptr = list.getList();} 01941 01946 inline void set(struct addrinfo *list) 01947 {ptr = list;} 01948 01953 inline void set(Socket::address& list) 01954 {ptr = list.getList();} 01955 01956 01961 inline struct sockaddr* operator->() const 01962 {return _getaddrinfo(ptr);} 01963 01968 inline bool operator!() const 01969 {return ptr == NULL;} 01970 01971 inline void next(void) 01972 {ptr = _nextaddrinfo(ptr);} 01973 }; 01974 01980 inline struct addrinfo *addrinfo(Socket::address& address) 01981 {return address.getList();} 01982 01989 inline struct sockaddr *addr(Socket::address& address) 01990 {return address.get();} 01991 01999 inline bool eq(const struct sockaddr *s1, const struct sockaddr *s2) 02000 {return Socket::equal(s1, s2);} 02001 02009 inline bool eq(const struct sockaddr_storage *s1, const struct sockaddr_storage *s2) 02010 {return Socket::equal((const struct sockaddr *)s1, (const struct sockaddr *)s2);} 02011 02019 inline bool eq_host(const struct sockaddr *s1, const struct sockaddr *s2) 02020 {return Socket::eq_host(s1, s2);} 02021 02022 inline bool eq_subnet(const struct sockaddr *s1, const struct sockaddr *s2) 02023 {return Socket::eq_subnet(s1, s2);} 02024 02025 String str(Socket& so, strsize_t size); 02026 02027 typedef TCPServer tcpserv_t; 02028 02029 } // namespace ucommon 02030 02031 #endif