ucommon
|
00001 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks. 00002 // 00003 // This file is part of GNU uCommon C++. 00004 // 00005 // GNU uCommon C++ is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published 00007 // by the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // GNU uCommon C++ is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>. 00017 00026 #ifndef _UCOMMON_SOCKET_H_ 00027 #define _UCOMMON_SOCKET_H_ 00028 00029 #ifndef _UCOMMON_TIMERS_H_ 00030 #include <ucommon/timers.h> 00031 #endif 00032 00033 #ifndef _UCOMMON_LINKED_H_ 00034 #include <ucommon/linked.h> 00035 #endif 00036 00037 #ifndef _UCOMMON_STRING_H_ 00038 #include <ucommon/string.h> 00039 #endif 00040 00041 extern "C" { 00042 struct addrinfo; 00043 } 00044 00045 #ifdef _MSWINDOWS_ 00046 #define SHUT_RDWR SD_BOTH 00047 #define SHUT_WR SD_SEND 00048 #define SHUT_RD SD_RECV 00049 typedef uint16_t in_port_t; 00050 typedef uint32_t in_addr_t; 00051 #else 00052 #include <unistd.h> 00053 #include <sys/socket.h> 00054 #include <net/if.h> 00055 #include <netinet/in.h> 00056 #include <netdb.h> 00057 #endif 00058 00059 #if defined(__ANDROID__) 00060 typedef uint16_t in_port_t; 00061 #endif 00062 00063 #include <errno.h> 00064 #include <stdio.h> 00065 00066 #ifndef IPTOS_LOWDELAY 00067 #define IPTOS_LOWDELAY 0x10 00068 #define IPTOS_THROUGHPUT 0x08 00069 #define IPTOS_RELIABILITY 0x04 00070 #define IPTOS_MINCOST 0x02 00071 #endif 00072 00073 #ifdef AF_UNSPEC 00074 #define DEFAULT_FAMILY AF_UNSPEC 00075 #else 00076 #define DEFAULT_FAMILY AF_INET 00077 #endif 00078 00079 struct sockaddr_internet; 00080 00081 typedef struct sockaddr *sockaddr_t; 00082 00083 typedef struct sockaddr sockaddr_struct; // older gcc needs...? 00084 00088 typedef struct hostaddr_internet 00089 { 00090 union 00091 { 00092 struct in_addr ipv4; 00093 #ifdef AF_INET6 00094 struct in6_addr ipv6; 00095 #endif 00096 }; 00097 } inethostaddr_t; 00098 00099 #if defined(AF_INET6) || defined(__CYGWIN__) 00100 00107 typedef struct sockaddr_internet 00108 { 00109 union { 00110 #ifdef AF_INET6 00111 struct sockaddr_in6 ipv6; 00112 #endif 00113 struct sockaddr_in ipv4; 00114 struct sockaddr address; 00115 }; 00116 } inetsockaddr_t; 00117 #else 00118 typedef struct sockaddr_internet 00119 { 00120 union { 00121 struct sockaddr_in ipv4; 00122 struct sockaddr address; 00123 }; 00124 } inetsockaddr_t; 00125 00126 struct sockaddr_storage 00127 { 00128 #ifdef AF_UNIX 00129 char sa_data[128]; 00130 #else 00131 char sa_data[sizeof(struct sockaddr_in)]; 00132 #endif 00133 }; 00134 #endif 00135 00136 #ifndef SOCK_DCCP 00137 #define SOCK_DCCP 6 00138 #endif 00139 00140 #ifndef IPPROTO_DCCP 00141 #define IPPROTO_DCCP 23 00142 #endif 00143 00144 #ifndef SOL_DCCP 00145 #define SOL_DCCP 269 00146 #endif 00147 00148 #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12 00149 #define DCCP_SOCKOPT_CCID 13 00150 #define DCCP_SOCKOPT_TX_CCID 14 00151 #define DCCP_SOCKOPT_RX_CCID 15 00152 00153 namespace ucommon { 00154 00164 class __EXPORT cidr : public LinkedObject 00165 { 00166 protected: 00167 int Family; 00168 inethostaddr_t Netmask, Network; 00169 char Name[16]; 00170 00171 unsigned mask(const char *cp) const; 00172 00173 inethostaddr_t broadcast(void) const; 00174 00175 unsigned mask(void) const; 00176 00177 public: 00181 typedef LinkedObject policy; 00182 00186 cidr(); 00187 00194 cidr(const char *string); 00195 00201 cidr(policy **policy, const char *string); 00202 00209 cidr(policy **policy, const char *string, const char *name); 00210 00215 cidr(const cidr& existing); 00216 00223 static const cidr *find(const policy *policy, const struct sockaddr *address); 00224 00232 static const cidr *container(const policy *policy, const struct sockaddr *address); 00233 00241 inline const char *getName(void) const 00242 {return Name;} 00243 00248 inline int getFamily(void) const 00249 {return Family;} 00250 00255 inline inethostaddr_t getNetwork(void) const 00256 {return Network;} 00257 00262 inline inethostaddr_t getNetmask(void) const 00263 {return Netmask;} 00264 00269 inline inethostaddr_t getBroadcast(void) const 00270 {return broadcast();} 00271 00276 inline unsigned getMask(void) const 00277 {return mask();} 00278 00283 void set(const char *string); 00284 00290 bool is_member(const struct sockaddr *address) const; 00291 00297 inline bool operator==(const struct sockaddr *address) const 00298 {return is_member(address);} 00299 00305 inline bool operator!=(const struct sockaddr *address) const 00306 {return !is_member(address);} 00307 }; 00308 00316 class __EXPORT Socket 00317 { 00318 protected: 00319 socket_t so; 00320 int ioerr; 00321 timeout_t iowait; 00322 00323 public: 00332 static struct addrinfo *query(const char *host, const char *service, int type = SOCK_STREAM, int protocol = 0); 00333 00339 static void release(struct addrinfo *list); 00340 00349 class __EXPORT address 00350 { 00351 protected: 00352 struct addrinfo *list; 00353 00354 public: 00365 address(int family, const char *address, int type = SOCK_STREAM, int protocol = 0); 00366 00379 address(int family, const char *hostname, const char *service = NULL); 00380 00387 address(const char *host, const char *service, int type = SOCK_STREAM); 00388 00396 address(const char *hostname, in_port_t port = 0); 00397 00401 address(const in_addr& address, in_port_t port = 0); 00402 00406 address(const in6_addr& address, in_port_t port = 0); 00407 00411 address(const sockaddr& address) : list(NULL) 00412 {insert(address);} 00413 00417 address(const addrinfo* list) : list(NULL) 00418 {insert(list);} 00419 00423 address(); 00424 00429 address(const address& reference); 00430 00434 ~address(); 00435 00441 bool operator==(const address& other) const; 00442 00443 inline bool operator!=(const address& other) const 00444 {return !(*this==other);} 00445 00446 inline bool equals(const address& other) const 00447 {return *this == other;} 00448 00453 struct sockaddr *get(void) const; 00454 00455 inline struct sockaddr *getAddr(void) const 00456 {return get();} 00457 00458 inline struct sockaddr *operator()(void) const 00459 {return get();} 00460 00465 inline operator struct sockaddr *() const 00466 {return get();} 00467 00473 struct sockaddr *get(int family) const; 00474 00475 inline struct sockaddr *operator()(int family) const 00476 {return get(family);} 00477 00478 inline operator struct sockaddr_in *() const 00479 {return (struct sockaddr_in *)get(AF_INET);} 00480 00481 #ifdef AF_INET6 00482 inline operator struct sockaddr_in6 *() const 00483 {return (struct sockaddr_in6 *)get(AF_INET6);} 00484 #endif 00485 00490 int family(void) const; 00491 00496 inline size_t getLength(void) const 00497 {return len(get());} 00498 00503 inline in_port_t getPort(void) const 00504 {return getPort(get());} 00505 00510 void setPort(in_port_t port); 00511 00516 address withPort(in_port_t port) const; 00517 00522 struct sockaddr *find(const struct sockaddr *addr) const; 00523 00528 inline struct addrinfo *getList(void) const 00529 {return list;} 00530 00535 inline operator struct addrinfo *() const 00536 {return list;} 00537 00542 inline struct addrinfo *operator*() const 00543 {return list;} 00544 00557 size_t print(char* dst, size_t dst_sz, bool port=false, bool force_brackets=false) const 00558 {return print(get(), dst, dst_sz, port, force_brackets);} 00559 00564 inline operator bool() const 00565 {return list != NULL;} 00566 00571 inline bool operator!() const 00572 {return list == NULL;} 00573 00579 inline bool isAny() const 00580 {return isAny(get());} 00581 00588 void setAny(int family = AF_UNSPEC); 00589 00595 inline bool isLoopback() const 00596 {return isLoopback(get());} 00597 00604 void setLoopback(int family = AF_UNSPEC); 00605 00609 void clear(void); 00610 00617 void set(const char *hostname, const char *service = NULL, int type = SOCK_STREAM); 00618 00625 void add(const char *hostname, const char *service = NULL, int type = SOCK_STREAM); 00626 00634 void set(int family, const char *address, int type = SOCK_STREAM, int protocol = 0); 00635 00640 void add(sockaddr *address); 00641 00647 unsigned insert(const struct addrinfo *address); 00648 00654 unsigned remove(const struct addrinfo *address); 00655 00661 bool remove(const struct sockaddr *address); 00662 00669 bool insert(const struct sockaddr *address); 00670 inline bool insert(const struct sockaddr& address) 00671 {return insert(&address);} 00672 00678 void copy(const struct addrinfo *address); 00679 00684 void set(struct sockaddr *address); 00685 00691 void set(const char *hostname, in_port_t service = 0); 00692 00697 static size_t getLength(const struct sockaddr *address) 00698 {return len(address);} 00699 00704 static in_port_t getPort(const struct sockaddr *address); 00705 00711 static void setPort(struct sockaddr *address, in_port_t port); 00712 00718 static bool isAny(const struct sockaddr *address); 00719 00724 static void setAny(struct sockaddr *sa); 00725 00729 static sockaddr_storage any(int family); 00730 00736 static bool isLoopback(const struct sockaddr *address); 00737 00743 static void setLoopback(struct sockaddr *sa); 00744 00748 static sockaddr_storage loopback(int family); 00749 00755 static struct sockaddr *dup(struct sockaddr *address); 00756 00762 static struct sockaddr_in *ipv4(struct sockaddr *address); 00763 00764 #ifdef AF_INET6 00765 00770 static struct sockaddr_in6 *ipv6(struct sockaddr *address); 00771 #endif 00772 00785 static size_t print(const struct sockaddr *src, char* dst, size_t dst_sz, bool port=false, bool ipv6_brackets=false); 00786 }; 00787 00788 friend class address; 00789 00793 Socket(); 00794 00799 Socket(const Socket& existing); 00800 00805 Socket(socket_t socket); 00806 00812 Socket(struct addrinfo *address); 00813 00820 Socket(int family, int type, int protocol = 0); 00821 00831 Socket(const char *address, const char *port, int family = AF_UNSPEC, int type = 0, int protocol = 0); 00832 00836 virtual ~Socket(); 00837 00841 void cancel(void); 00842 00847 static void cancel(socket_t socket); 00848 00852 void release(void); 00853 00857 inline int err(void) const 00858 {return ioerr;} 00859 00865 bool is_pending(unsigned value) const; 00866 00871 bool connected(void) const; 00872 00879 bool wait(timeout_t timeout = 0) const; 00880 00885 inline int nodelay(void) const 00886 {return nodelay(so);} 00887 00895 static bool wait(socket_t socket, timeout_t timeout = 0); 00896 00903 bool waitSending(timeout_t timeout = 0) const; 00904 00909 inline unsigned pending(void) const 00910 {return pending(so);} 00911 00917 inline int broadcast(bool enable) 00918 {return broadcast(so, enable);} 00919 00925 inline int keepalive(bool enable) 00926 {return keepalive(so, enable);} 00927 00933 inline int blocking(bool enable) 00934 {return blocking(so, enable);} 00935 00941 inline int multicast(unsigned ttl = 1) 00942 {return multicast(so, ttl);} 00943 00949 inline int loopback(bool enable) 00950 {return loopback(so, enable);} 00951 00956 inline int getError(void) 00957 {return error(so);} 00958 00964 inline int ttl(unsigned char time) 00965 {return ttl(so, time);} 00966 00972 inline int sendsize(unsigned size) 00973 {return sendsize(so, size);} 00974 00980 inline int sendwait(unsigned size) 00981 {return sendwait(so, size);} 00982 00983 00989 inline int recvsize(unsigned size) 00990 {return recvsize(so, size);} 00991 00997 static int type(socket_t socket); 00998 01005 static unsigned segsize(socket_t socket, unsigned size = 0); 01006 01013 static bool ccid(socket_t socket, uint8_t id); 01014 01019 inline int type(void) 01020 {return type(so);} 01021 01027 inline unsigned segsize(unsigned size) 01028 {return segsize(so, size);} 01029 01035 inline bool ccid(uint8_t id) 01036 {return ccid(so, id);} 01037 01046 inline int tos(int type) 01047 {return tos(so, type);} 01048 01055 inline int priority(int scheduling) 01056 {return priority(so, scheduling);} 01057 01061 inline void shutdown(void) 01062 {::shutdown(so, SHUT_RDWR);} 01063 01071 int connectto(struct addrinfo *list); 01072 01079 int disconnect(void); 01080 01086 int join(const struct addrinfo *list, const int ifindex = 0); 01087 01093 int drop(const struct addrinfo *list, const int ifindex = 0); 01094 01100 int wait(timeout_t timeout = Timer::inf); 01101 01108 size_t peek(void *data, size_t number) const; 01109 01117 size_t readfrom(void *data, size_t number, struct sockaddr_storage *address = NULL); 01118 01126 size_t writeto(const void *data, size_t number, const struct sockaddr *address = NULL); 01127 01140 size_t readline(char *data, size_t size); 01141 01147 size_t printf(const char *format, ...) __PRINTF(2,3); 01148 01160 size_t readline(String& buffer); 01161 01173 static ssize_t readline(socket_t socket, char *data, size_t size, timeout_t timeout = Timer::inf); 01174 01181 static ssize_t printf(socket_t socket, const char *format, ...) __PRINTF(2,3); 01182 01190 size_t writes(const char *string); 01191 01196 operator bool(); 01197 01202 bool operator!() const; 01203 01209 Socket& operator=(socket_t socket); 01210 01215 inline operator socket_t() const 01216 {return so;} 01217 01222 inline socket_t operator*() const 01223 {return so;} 01224 01231 static unsigned pending(socket_t socket); 01232 01239 static int sendsize(socket_t socket, unsigned size); 01240 01247 static int sendwait(socket_t socket, unsigned size); 01248 01255 static int recvsize(socket_t socket, unsigned size); 01256 01265 static int connectto(socket_t socket, struct addrinfo *list); 01266 01272 static int disconnect(socket_t socket); 01273 01280 static int drop(socket_t socket, const struct addrinfo *list, const int ifindex = 0); 01281 01288 static int join(socket_t socket, const struct addrinfo *list, const int ifindex = 0); 01289 01295 static int error(socket_t socket); 01296 01303 static int multicast(socket_t socket, unsigned ttl = 1); 01304 01311 static int loopback(socket_t socket, bool enable); 01312 01319 static int blocking(socket_t socket, bool enable); 01320 01327 static int keepalive(socket_t socket, bool enable); 01328 01335 static int broadcast(socket_t socket, bool enable); 01336 01342 static int nodelay(socket_t socket); 01343 01350 static int priority(socket_t socket, int scheduling); 01351 01358 static int tos(socket_t socket, int type); 01359 01366 static int ttl(socket_t socket, unsigned char time); 01367 01372 static int family(socket_t socket); 01373 01379 inline static int family(const struct sockaddr_storage& address) 01380 {return ((const struct sockaddr *)&address)->sa_family;} 01381 01387 inline static int family(const struct sockaddr_internet& address) 01388 {return address.address.sa_family;} 01389 01399 static ssize_t recvfrom(socket_t socket, void *buffer, size_t size, int flags = 0, struct sockaddr_storage *address = NULL); 01400 01410 static ssize_t sendto(socket_t socket, const void *buffer, size_t size, int flags = 0, const struct sockaddr *address = NULL); 01411 01421 inline static ssize_t replyto(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_storage *address) 01422 {return sendto(socket, buffer, size, flags, (const struct sockaddr *)address);} 01423 01433 inline static ssize_t sendinet(socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_internet *address) 01434 {return sendto(socket, buffer, size, flags, (const struct sockaddr *)address);} 01435 01445 static ssize_t recvinet(socket_t socket, void *buffer, size_t size, int flags = 0, struct sockaddr_internet *address = NULL); 01446 01455 static int bindto(socket_t socket, const char *address, const char *service, int protocol = 0); 01456 01464 static int listento(socket_t socket, const struct sockaddr *address, int backlog = 5); 01465 01472 static int bindto(socket_t socket, const struct sockaddr *address); 01473 01480 static socket_t acceptfrom(socket_t socket, struct sockaddr_storage *address = NULL); 01481 01489 static socket_t create(int family, int type, int protocol); 01490 01498 static socket_t create(const struct addrinfo *address, int type, int protocol); 01499 01509 static socket_t create(const char *iface, const char *service, int family = AF_UNSPEC, int type = 0, int protocol = 0); 01510 01516 static socket_t create(const Socket::address &address); 01517 01522 static void release(socket_t socket); 01523 01531 static char *hostname(const struct sockaddr *address, char *buffer, size_t size); 01532 01540 static struct addrinfo *hinting(socket_t socket, struct addrinfo *hint); 01541 01552 static socklen_t query(socket_t socket, struct sockaddr_storage *address, const char *hostname, const char *service); 01553 01559 static socklen_t len(const struct sockaddr *address); 01560 01568 static bool equal(const struct sockaddr *address1, const struct sockaddr *address2); 01569 01576 static unsigned copy(struct sockaddr *target, const struct sockaddr *origin); 01577 01584 inline static unsigned store(struct sockaddr_storage *storage, const struct sockaddr *address) 01585 {return copy((struct sockaddr*)storage, address);} 01586 01593 static unsigned store(struct sockaddr_internet *storage, const struct sockaddr *address); 01594 01602 static bool eq_host(const struct sockaddr *address1, const struct sockaddr *address2); 01603 01611 inline static bool eq_from(const struct sockaddr_storage *address1, const struct sockaddr_storage *address2) 01612 {return equal((const struct sockaddr *)address1, (const struct sockaddr *)address2);} 01613 01621 inline static bool eq_inet(const struct sockaddr_internet *address1, const struct sockaddr_internet *address2) 01622 {return equal((const struct sockaddr *)address1, (const struct sockaddr *)address2);} 01623 01631 static bool eq_subnet(const struct sockaddr *address1, const struct sockaddr *address2); 01632 01640 static int via(struct sockaddr *address, const struct sockaddr *destination); 01641 01649 static char *query(const struct sockaddr *address, char *buffer, socklen_t size); 01650 01656 static short service(const struct sockaddr *address); 01657 01663 inline static short service(const struct sockaddr_internet *address) 01664 {return service((const struct sockaddr *)address);} 01665 01672 static unsigned keyindex(const struct sockaddr *address, unsigned size); 01673 01680 static unsigned keyhost(const struct sockaddr *address, unsigned size); 01681 01685 static void init(void); 01686 01691 static void init(const char *program); 01692 01698 static void query(int family); 01699 01706 static void v4mapping(bool enable); 01707 01712 static int error(void); 01713 01722 static bool is_null(const char *string); 01723 01731 static bool is_numeric(const char *string); 01732 01741 static int local(socket_t socket, struct sockaddr_storage *address); 01742 01751 static int remote(socket_t socket, struct sockaddr_storage *address); 01752 }; 01753 01759 class __EXPORT ListenSocket : protected Socket 01760 { 01761 public: 01771 ListenSocket(const char *address, const char *service, unsigned backlog = 5, int family = AF_UNSPEC, int type = 0, int protocol = 0); 01772 01783 static socket_t create(const char *address, const char *service, unsigned backlog = 5, int family = AF_UNSPEC, int type = 0, int protocol = 0); 01784 01790 socket_t accept(struct sockaddr_storage *address = NULL) const; 01791 01797 inline bool wait(timeout_t timeout = Timer::inf) const 01798 {return Socket::wait(timeout);} 01799 01804 inline operator socket_t() const 01805 {return so;} 01806 01811 inline socket_t operator*() const 01812 {return so;} 01813 01818 inline socket_t getsocket(void) const 01819 {return so;} 01820 01821 inline socket_t handle(void) const 01822 {return so;} 01823 01824 }; 01825 01831 class __EXPORT TCPServer : public ListenSocket 01832 { 01833 public: 01841 TCPServer(const char *address, const char *service, unsigned backlog = 5); 01842 }; 01843 01847 __EXPORT struct addrinfo *_nextaddrinfo(struct addrinfo *addrinfo); 01848 01852 __EXPORT struct sockaddr *_getaddrinfo(struct addrinfo *addrinfo); 01853 01857 __EXPORT socket_t _getaddrsock(struct addrinfo *addrinfo); 01858 01864 template <> 01865 class linked_pointer<sockaddr_struct> 01866 { 01867 private: 01868 struct addrinfo *ptr; 01869 01870 public: 01871 inline linked_pointer(struct addrinfo *list) 01872 {ptr = list;} 01873 01874 inline linked_pointer() 01875 {ptr = NULL;} 01876 01877 inline linked_pointer(Socket::address& list) 01878 {ptr = list.getList();} 01879 01884 inline operator struct sockaddr *() const 01885 {return _getaddrinfo(ptr);} 01886 01891 inline struct sockaddr *operator*() const 01892 {return _getaddrinfo(ptr);} 01893 01894 inline operator struct sockaddr_in *() const 01895 {return (struct sockaddr_in *)_getaddrinfo(ptr);} 01896 01897 inline struct sockaddr_in *in(void) const 01898 {return (struct sockaddr_in *)_getaddrinfo(ptr);} 01899 01900 #ifdef AF_INET6 01901 inline operator struct sockaddr_in6 *() const 01902 {return (struct sockaddr_in6 *)_getaddrinfo(ptr);} 01903 01904 inline struct sockaddr_in6 *in6(void) const 01905 {return (struct sockaddr_in6 *)_getaddrinfo(ptr);} 01906 #endif 01907 01911 inline socket_t operator()(void) const 01912 {return _getaddrsock(ptr);} 01913 01918 inline operator bool() const 01919 {return ptr != NULL;} 01920 01925 inline void operator=(struct addrinfo *list) 01926 {ptr = list;} 01927 01932 inline void operator=(Socket::address& list) 01933 {ptr = list.getList();} 01934 01939 inline void set(struct addrinfo *list) 01940 {ptr = list;} 01941 01946 inline void set(Socket::address& list) 01947 {ptr = list.getList();} 01948 01949 01954 inline struct sockaddr* operator->() const 01955 {return _getaddrinfo(ptr);} 01956 01961 inline bool operator!() const 01962 {return ptr == NULL;} 01963 01964 inline void next(void) 01965 {ptr = _nextaddrinfo(ptr);} 01966 }; 01967 01973 inline struct addrinfo *addrinfo(Socket::address& address) 01974 {return address.getList();} 01975 01982 inline struct sockaddr *addr(Socket::address& address) 01983 {return address.get();} 01984 01992 inline bool eq(const struct sockaddr *s1, const struct sockaddr *s2) 01993 {return Socket::equal(s1, s2);} 01994 02002 inline bool eq(const struct sockaddr_storage *s1, const struct sockaddr_storage *s2) 02003 {return Socket::equal((const struct sockaddr *)s1, (const struct sockaddr *)s2);} 02004 02012 inline bool eq_host(const struct sockaddr *s1, const struct sockaddr *s2) 02013 {return Socket::eq_host(s1, s2);} 02014 02015 inline bool eq_subnet(const struct sockaddr *s1, const struct sockaddr *s2) 02016 {return Socket::eq_subnet(s1, s2);} 02017 02018 String str(Socket& so, strsize_t size); 02019 02020 typedef TCPServer tcpserv_t; 02021 02022 } // namespace ucommon 02023 02024 #endif