8 #ifndef INCL_evo_iosock_h 9 #define INCL_evo_iosock_h 17 #include <sys/select.h> 33 static const socklen_t
MAX_SIZE =
sizeof(sockaddr_in6);
49 memcpy(&addr_ip6, &src.
addr_ip6,
sizeof(sockaddr_in6));
70 memcpy(&addr_ip6, ptr, (
addrlen=
sizeof(sockaddr_in6)));
80 addr_ip6.sin6_family = AF_INET6;
81 addr_ip6.sin6_addr = in6addr_any;
82 addr_ip6.sin6_port = htons(port);
85 addr_ip4.sin_addr.s_addr = INADDR_ANY;
104 switch (ptr->sa_family) {
105 case AF_INET:
set((
struct sockaddr_in*)ptr);
break;
106 case AF_INET6:
set((
struct sockaddr_in6*)ptr);
break;
119 {
return (
addr.sa_family != 0); }
134 memcpy(&addr_ip6, &src.addr_ip6,
sizeof(
struct sockaddr_in6));
159 memcpy(&addr_ip6, ptr, (
addrlen=
sizeof(
struct sockaddr_in6)));
169 if (ptr != NULL && ptr->ai_addr != NULL && ptr->ai_addrlen > 0) {
170 switch (ptr->ai_family) {
171 case AF_INET: memcpy(&
addr_ip4, ptr->ai_addr, (
addrlen=
sizeof(
struct sockaddr_in)));
break;
172 case AF_INET6: memcpy(&addr_ip6, ptr->ai_addr, (
addrlen=
sizeof(
struct sockaddr_in6)));
break;
185 switch (
addr.sa_family) {
186 case AF_INET:
addr_ip4.sin_port = htons(port);
break;
187 case AF_INET6: addr_ip6.sin6_port = htons(port);
break;
199 addr_ip4.sin_addr.s_addr = INADDR_ANY;
210 addr_ip6.sin6_family = AF_INET6;
211 addr_ip6.sin6_addr = in6addr_any;
212 addr_ip6.sin6_port = htons(port);
220 const char* pstr = str.
data();
221 const char* pend = pstr + str.
size();
223 if (family == AF_UNSPEC) {
226 for (
const char* p=pstr; p < pend; ++p, ++i) {
231 if (*p < '0' || *p >
'9') {
236 family = (i < 0 ? AF_INET6 : AF_INET);
244 ushort num, shift = 32;
245 const char* p = pstr;
246 for (uint i=0; i < 4; ++i) {
252 if (p == pend || *p !=
'.')
259 ip |= (num << shift);
261 addr_ip4.sin_addr.s_addr = htonl(ip);
273 addrlen =
sizeof(
struct sockaddr_in);
279 const char* p = pstr;
281 bool brackets =
false;
288 const uint MAX_NUMS = 8;
289 const uint MAX_IPLEN = MAX_NUMS * 2;
290 uint head_len = MAX_IPLEN;
293 if (++p == pend || *p !=
':')
295 if (++p < pend && *p ==
']') {
305 uchar* ip = addr_ip6.sin6_addr.s6_addr;
308 for (; p < pend && i <= MAX_NUMS; ++i) {
310 if (head_len < MAX_IPLEN)
312 head_len = (uint)(p_ip - ip);
323 if (i < MAX_NUMS && head_len == MAX_IPLEN)
325 }
else if (*p ==
'%') {
327 }
else if (i < MAX_NUMS) {
332 if ((uint)(pend - p) > MAX_INET4_STRLEN + 1)
334 const uint MAX_IP4LEN = 4;
335 for (uint j=1; j <= MAX_IP4LEN; ++j) {
339 if (j < MAX_IP4LEN) {
340 if (p == pend || *p !=
'.')
350 }
else if (*p ==
']') {
353 *p_ip = (uchar)((num >> 8) & 0xFF);
354 *++p_ip = (uchar)(num & 0xFF);
357 }
else if (*p !=
':')
361 *p_ip = (uchar)((num >> 8) & 0xFF);
362 *++p_ip = (uchar)(num & 0xFF);
367 if (head_len < MAX_IPLEN) {
368 uint ip_mov_len = (uint)(p_ip - ip);
369 if (ip_mov_len >= MAX_IPLEN)
371 ip_mov_len -= head_len;
373 memmove(ip + MAX_IPLEN - ip_mov_len, ip + head_len, ip_mov_len);
374 memset(ip + head_len, 0, MAX_IPLEN - ip_mov_len - head_len);
378 if (p < pend && *p ==
'%') {
383 if (*p < '0' || *p >
'9') {
384 const char* p0 =
str_scan_to(IF_NAMESIZE-1, p, pend,
']',
':');
385 if (p0 == NULL || p0 == pend)
387 const uint len = p0 - p;
388 char buf[IF_NAMESIZE];
390 if ((i = if_nametoindex(buf)) != 0)
392 addr_ip6.sin6_scope_id = i;
402 if (p == pend || *p !=
']')
409 if (*p !=
':' || ++p == pend)
414 addr_ip6.sin6_port = htons(num);
417 addr_ip6.sin6_port = htons(port);
419 addrlen =
sizeof(
struct sockaddr_in6);
425 addr.sa_family = (ushort)family;
442 if (address != NULL) {
444 switch (address_base->
addr.sa_family) {
446 struct sockaddr_in* sock_addr = (
struct sockaddr_in*)&address_base->
addr;
447 if (sock_addr->sin_port > 0) {
448 const ushort port = ntohs(sock_addr->sin_port);
449 char* buf = str.
advWrite(MAX_INET4_STRLEN);
450 if (inet_ntop(AF_INET, (
void*)&sock_addr->sin_addr, buf, MAX_INET4_STRLEN) != NULL) {
452 buf[addrlen++] =
':';
458 char* buf = str.
advWrite(MAX_INET4_STRLEN);
459 if (inet_ntop(AF_INET, (
void*)&sock_addr->sin_addr, buf, MAX_INET4_STRLEN) != NULL) {
467 struct sockaddr_in6* sock_addr = (
struct sockaddr_in6*)&address_base->
addr;
468 if (sock_addr->sin6_port > 0) {
469 const ushort port = ntohs(sock_addr->sin6_port);
470 char* buf = str.
advWrite(MAX_INET6_STRLEN);
472 if (inet_ntop(AF_INET6, (
void*)&sock_addr->sin6_addr, buf+1, MAX_INET6_STRLEN-1) != NULL) {
474 buf[addrlen++] =
']';
475 buf[addrlen++] =
':';
481 char* buf = str.
advWrite(MAX_INET6_STRLEN);
482 if (inet_ntop(AF_INET6, (
void*)&sock_addr->sin6_addr, buf, MAX_INET6_STRLEN) != NULL) {
500 switch (addr->sa_family) {
501 case AF_INET:
return true;
502 case AF_INET6:
return true;
516 static const socklen_t
MAX_SIZE =
sizeof(sockaddr_un);
520 struct sockaddr_un addr_unix;
531 memcpy(&addr_unix, &src.
addr_unix,
sizeof(sockaddr_un));
548 if (ptr != NULL && ptr->sa_family == AF_UNIX)
549 set((
struct sockaddr_un*)ptr);
560 {
return (
addr.sa_family != 0); }
575 memcpy(&addr_unix, &src.addr_unix, (
addrlen=src.addrlen));
584 if (ptr == NULL || ptr->sun_family != AF_UNIX)
587 memcpy(&addr_unix, ptr, (
addrlen=offsetof(
struct sockaddr_un, sun_path) + strlen(ptr->sun_path)));
599 if (pathlen+1 <
sizeof(addr_unix.sun_path)) {
600 bzero((
char*)&addr_unix,
sizeof(addr_unix));
601 addr_unix.sun_family = AF_UNIX;
603 memcpy(addr_unix.sun_path, path.
data(), pathlen);
604 addr_unix.sun_path[pathlen] =
'\0';
606 addrlen = pathlen + offsetof(
struct sockaddr_un, sun_path);
629 if (address != NULL) {
631 if (address_base->
addr.sa_family == AF_UNIX) {
632 const struct sockaddr_un* address_unix = (
struct sockaddr_un*)&address_base->
addr;
633 str.
copy(address_unix->sun_path, address_base->
addrlen - offsetof(
struct sockaddr_un, sun_path));
645 if (addr != NULL && addr->sa_family == AF_UNIX)
738 static const int BACKLOG_DEFAULT = 5;
749 { excep(exceptions); }
759 { excep(exceptions); }
773 {
return device_.timeout_ms; }
782 { device_.timeout_ms = timeout_ms;
return *
this; }
793 {
return resolve_enable_; }
805 resolve_enable_ = enable;
822 uint size =
sizeof(T);
823 error_ = device_.getopt(level, optname, buf, size);
843 uint size =
sizeof(num);
844 error_ = device_.getopt(level, optname, &num, size);
866 bool set_opt(
int level,
int optname,
const T& val) {
867 error_ = device_.setopt(level, optname, (T*)&val,
sizeof(T));
868 if (error_ !=
ENone) {
888 return set_opt(level, optname, num);
900 bool listen_ip(
const SubString& host, ushort port,
int family=AF_INET,
int backlog=BACKLOG_DEFAULT) {
903 error_ = address_info.
resolve(host, port);
905 error_ = address_info.
convert(host, port);
906 if (error_ ==
ENone && device_.listen(error_, address_info.
ptr, backlog)) {
910 errno = address_info.
code;
921 bool listen_ip(ushort port,
int family=AF_INET,
int backlog=BACKLOG_DEFAULT) {
923 error_ = address_info.
resolve(NULL, port, AI_PASSIVE | AI_NUMERICSERV);
924 if (error_ ==
ENone && device_.listen(error_, address_info.
ptr, backlog)) {
928 errno = address_info.
code;
945 assert( path.
size_ > 0 );
953 if (address.
parse(path)) {
954 if (device_.listen(error_, &address.
addr, address.
addrlen, backlog))
957 errno = ENAMETOOLONG;
975 client_socket.
close();
976 if (client_address != NULL) {
978 client_address->set_maxsize();
980 if (device_.accept(error_, client_socket.
device_, client_address)) {
981 client_socket.
owned_ =
true;
997 bool connect_ip(
const char* host, ushort port,
int family=AF_INET) {
1000 if (resolve_enable_)
1001 error_ = address_info.
resolve(host, port);
1003 error_ = address_info.
convert(host, port);
1004 if (error_ ==
ENone && device_.connect(error_, address_info.
ptr)) {
1008 errno = address_info.
code;
1025 if (resolve_enable_)
1026 error_ = address_info.
resolve(host, port);
1028 error_ = address_info.
convert(host, port);
1029 if (error_ ==
ENone && device_.connect(error_, address_info.
ptr)) {
1033 errno = address_info.
code;
1048 assert( path.
size_ > 0 );
1056 if (address.
parse(path)) {
1057 if (device_.connect(error_, &address.
addr, address.
addrlen))
1060 errno = ENAMETOOLONG;
1077 {
return device_.shutdown(); }
1107 template<
class TOut>
1109 {
return IoSocket::errormsg_out<>(out, error_); }
1119 bool resolve_enable_;
1161 { excep(exceptions); }
1168 { excep(exceptions); }
1180 {
return device_.timeout_ms; }
1189 { device_.timeout_ms = timeout_ms;
return *
this; }
1204 uint size =
sizeof(T);
1205 error_ = device_.getopt(level, optname, buf, size);
1206 if (error_ ==
ENone)
1226 uint size =
sizeof(num);
1227 error_ = device_.getopt(level, optname, &num, size);
1230 if (error_ ==
ENone)
1249 bool set_opt(
int level,
int optname,
const T& val) {
1250 error_ = device_.setopt(level, optname, (T*)&val,
sizeof(T));
1251 if (error_ !=
ENone) {
1271 return set_opt(level, optname, num);
1281 if (!device_.bind(error_, &((
SocketAddress&)address).addr, address.
addrlen, socktype, protocol)) {
1299 if (family == AF_UNSPEC) {
1300 if (address != NULL)
1305 target_address_ = address;
1306 if (!device_.cast(error_, family, socktype, protocol)) {
1315 { device_.close(); }
1325 if (address == NULL)
1326 return device_.readfrom(error_, buf, size, NULL, 0, flags);
1327 address->set_maxsize();
1328 const ulong result = device_.readfrom(error_, buf, size, &((
SocketAddress*)address)->
addr, &address->
addrlen, flags);
1335 {
return read(buf, size); }
1345 if (address == NULL) {
1346 if (target_address_ == NULL) {
1351 address = target_address_;
1353 const ulong result = device_.writeto(error_, buf, size, &((
SocketAddress*)address)->
addr, address->
addrlen, flags);
1360 {
return write(buf, size); }
1369 template<
class TOut>
1371 {
return IoSocket::errormsg_out<>(out, error_); }
struct sockaddr addr
Generic address structure.
Definition: iosock.h:519
Error convert(const char *host)
Convert host address to one or more socket addresses.
Definition: sysio_sock.h:258
SocketAddressIp(struct sockaddr *ptr)
Constructor to copy IP address from sockaddr structure.
Definition: iosock.h:101
TOut & errormsg_out(TOut &out)
Write detailed error message with errno to output stream/string.
Definition: iosock.h:1370
bool bind(const SocketAddressBase &address, int socktype=SOCK_DGRAM, int protocol=0)
Create and bind datagram socket to address (read/write).
Definition: iosock.h:1280
T * advWrite(Size addsize)
Advanced: Get buffer pointer to write/append (modifier).
Definition: list.h:2768
struct sockaddr addr
Generic address structure.
Definition: sysio_sock.h:114
Socket for I/O casting (datagram/UDP).
Definition: iosock.h:1155
bool connect_ud(const SubString &path)
Connect to Unix Domain socket at file path (linux/unix).
Definition: iosock.h:1047
Shutdown input (reads) on socket.
Definition: sysio_sock.h:688
String & copy(const ListType &str)
Set as full (unshared) copy of another string (modifier).
Definition: string.h:2705
TOut & errormsg_out(TOut &out)
Write detailed error message with errno to output stream/string.
Definition: iosock.h:1108
bool cast(const SocketAddressBase *address=NULL, int family=AF_UNSPEC, int socktype=SOCK_DGRAM, int protocol=0)
Create unbound datagram socket for casting (write only).
Definition: iosock.h:1298
SocketAddressIp(struct addrinfo *ptr)
Constructor to copy from addrinfo structure.
Definition: iosock.h:93
Socket config exception for getopt() or setopt() errors, see Exception.
Definition: sysio_sock.h:73
Evo string scanning helpers with SSE optimized code.
Invalid argument or data.
Definition: sys.h:1123
SocketCast & set_timeout(ulong timeout_ms)
Set timeout for socket operations.
Definition: iosock.h:1188
SocketAddressIp & setany4(ushort port=0)
Set as wildcard IPv4 address.
Definition: iosock.h:196
bool listen_ud(const SubString &path, int backlog=BACKLOG_DEFAULT)
Create and bind Unix Domain socket to file path and listen for connections (linux/unix).
Definition: iosock.h:944
socklen_t addrlen
Address length.
Definition: sysio_sock.h:96
bool valid() const
Get whether valid.
Definition: iosock.h:118
Long get_opt_num(int level, int optname)
Get socket option flag or numeric value.
Definition: iosock.h:841
Socket open exception for socket connect/bind/listen errors, see Exception.
Definition: sysio_sock.h:77
SocketCast(bool exceptions=1)
Constructor.
Definition: iosock.h:1160
static bool format_addr(String &str, const SocketAddressBase *address)
Format Unix Domain socket address to given string (appended).
Definition: iosock.h:628
ulong write(const void *buf, ulong size, int flags=0, const SocketAddressBase *address=NULL)
Write message to socket.
Definition: iosock.h:1344
SocketAddressIp & setany6(ushort port=0)
Set as wildcard IPv6 address.
Definition: iosock.h:208
Stream< IoSocket > Base
Base class alias (used internally)
Definition: iosock.h:736
void set_maxsize()
Set addrlen to max size for socket address.
Definition: iosock.h:112
bool set_opt(int level, int optname, const T &val)
Set socket option value.
Definition: iosock.h:1249
bool finish()
Finish (shutdown) socket input and output (reads and writes).
Definition: iosock.h:1076
Newline
Newline type.
Definition: sys.h:748
SocketAddressUnix()
Default constructor sets as empty/invalid.
Definition: iosock.h:524
static const uint MAX_INET6_STRLEN
Max IPv6 string length with IPv4 tunneling, brackets, zone/scope ID, and port num + terminator...
Definition: iosock.h:31
#define EVO_THROW_ERR_CHECK(TYPE, MSG, ERROR, COND)
Throw an Evo exception with error code if COND is true.
Definition: sys.h:1513
T device_
I/O device.
Definition: iobase.h:1687
bool parse(const SubString &path)
Parse Unix Domain socket address.
Definition: iosock.h:597
SocketAddressIp(ushort port, bool ip6=false)
Constructor for wildcard address.
Definition: iosock.h:77
Evo I/O streams and Console I/O.
ulong get_timeout() const
Get timeout for socket operations.
Definition: iosock.h:772
Socket input stream exception for socket read errors, see Exception.
Definition: sysio_sock.h:81
void advWriteDone(Size addsize)
Advanced: Update size added after writing directly to buffer.
Definition: list.h:2784
static const socklen_t MAX_SIZE
Max socket address size used here.
Definition: iosock.h:33
Basic integer type.
Definition: type.h:980
SocketAddressUnix(struct sockaddr *ptr)
Constructor to copy Unix Domain socket address from sockaddr structure.
Definition: iosock.h:546
struct sockaddr_un addr_unix
Unix Domain address structure (union with addr)
Definition: iosock.h:520
Long get_opt_num(int level, int optname)
Get socket option flag or numeric value.
Definition: iosock.h:1224
SocketAddressIp & setport(ushort port)
Set port on current address.
Definition: iosock.h:184
StrSizeT Size
List size integer type
Definition: list.h:247
bool connect_ip(const SubString &host, ushort port, int family=AF_INET)
Connect TCP socket to host address.
Definition: iosock.h:1022
Size size() const
Get size.
~SocketCast()
Destructor.
Definition: iosock.h:1171
struct addrinfo * ptr
Pointer to first address in resolve results.
Definition: sysio_sock.h:127
Size limit exceeded.
Definition: sys.h:1139
No error.
Definition: sys.h:1115
SocketAddressUnix(const SocketAddressUnix &src)
Copy constructor.
Definition: iosock.h:530
#define EVO_EXCEPTIONS
Whether to throw exceptions on error by default.
Definition: evo_config.h:35
static const Init & init()
Initialize socket library.
Definition: sysio_sock.h:1360
bool connect_ip(const char *host, ushort port, int family=AF_INET)
Connect TCP socket to host address.
Definition: iosock.h:997
int OptNum
General number type for socket options.
Definition: sysio_sock.h:698
bool close()
Close stream.
Definition: iobase.h:888
struct sockaddr_in addr_ip4
IPv4 address structure (union with addr)
Definition: iosock.h:37
Socket output stream exception for socket write errors, see Exception.
Definition: sysio_sock.h:85
StrSizeT Size
List size integer type.
Definition: sublist.h:150
String container.
Definition: string.h:674
Socket I/O device (used internally).
Definition: sysio_sock.h:307
bool accept(Socket &client_socket, SocketAddressBase *client_address=NULL)
Accept connection from listening socket.
Definition: iosock.h:974
SocketAddressIp()
Default constructor sets as empty/invalid.
Definition: iosock.h:42
ulong get_timeout() const
Get timeout for socket operations.
Definition: iosock.h:1179
Socket I/O stream.
Definition: iosock.h:734
Base binary stream interface.
Definition: iobase.h:30
int code
Internal return code from resolve()
Definition: sysio_sock.h:128
bool set_opt_num(int level, int optname, long val)
Set socket option flag or numeric value.
Definition: iosock.h:1269
const char * str_scan_to(uint maxlen, const char *str, const char *end, char ch)
Scan string pointer for char and return stop pointer.
Definition: strscan.h:1775
Socket & set_resolve(bool enable)
Set whether full resolver is used when resolving addresses.
Definition: iosock.h:804
SocketAddressIp(struct sockaddr_in6 *ptr)
Constructor to copy from an IPv6 address.
Definition: iosock.h:66
bool set_opt_num(int level, int optname, long val)
Set socket option flag or numeric value.
Definition: iosock.h:886
void close()
Close socket.
Definition: iosock.h:1314
static bool format_addr(String &str, const SocketAddressBase *address)
Format IP address to given string (appended).
Definition: iosock.h:441
SocketAddressIp & clear()
Clear current address.
Definition: iosock.h:124
bool set_opt(int level, int optname, const T &val)
Set socket option value.
Definition: iosock.h:866
Evo C++ Library namespace.
Definition: alg.h:11
const char * str_scan_decimal(T &num, const char *str, const char *end)
Scan string pointer for decimal number and return stop pointer.
Definition: strscan.h:1826
bool format(String &str) const
Format Unix Domain socket address to given string (appended).
Definition: iosock.h:618
Error resolve(const char *host, const char *port=NULL, int flags=AI_NUMERICSERV)
Resolve or convert host name/address and port to one or more socket addresses.
Definition: sysio_sock.h:185
bool valid() const
Get whether valid.
Definition: iosock.h:559
Input/Output stream implementation.
Definition: iobase.h:791
static const uint MAX_INET4_STRLEN
Max IPv4 string length with port num + terminator.
Definition: iosock.h:30
Resolves socket name/address to socket address info.
Definition: sysio_sock.h:125
SocketAddressIp(struct sockaddr_in *ptr)
Constructor to copy from an IPv4 address.
Definition: iosock.h:56
static bool check(struct sockaddr *addr)
Check if address struct holds a supported Unix Domain socket address type.
Definition: iosock.h:644
void set_maxsize()
Set addrlen to max size for socket address.
Definition: iosock.h:553
TCP/IP socket address.
Definition: iosock.h:29
struct sockaddr_in6 addr_ip6
IPv6 address structure (union with addr)
Definition: iosock.h:38
static const Newline NL_SYS
Current system newline type.
Definition: sys.h:763
T * get_opt(int level, int optname, T *buf)
Get socket option value.
Definition: iosock.h:821
ulong readbin(void *buf, ulong size)
Read binary input from stream.
Definition: iosock.h:1334
bool owned_
Whether handle is owned (to be closed here)
Definition: iobase.h:1688
bool finish_out()
Finish (shutdown) socket output (writes).
Definition: iosock.h:1097
Evo system I/O socket implementation.
bool get_resolve() const
Get whether full resolver is used when resolving addresses.
Definition: iosock.h:792
TSize size_
Data size as item count, 0 if empty or null.
Definition: sys.h:980
const char * str_scan_hex(T &num, const char *str, const char *end)
Scan string pointer for hex number and return stop pointer.
Definition: strscan.h:1856
bool finish_in()
Finish (shutdown) socket input (reads).
Definition: iosock.h:1087
SocketAddressUnix & clear()
Clear current address.
Definition: iosock.h:565
IoSocket & device()
Access low-level I/O device for socket.
Definition: iosock.h:764
Socket(bool exceptions)
Constructor.
Definition: iosock.h:758
T * get_opt(int level, int optname, T *buf)
Get socket option value.
Definition: iosock.h:1203
bool listen_ip(const SubString &host, ushort port, int family=AF_INET, int backlog=BACKLOG_DEFAULT)
Create and bind TCP socket on host interface and listen for connections.
Definition: iosock.h:900
SocketCast(SocketAddressBase *address, bool exceptions=1)
Constructor.
Definition: iosock.h:1167
SocketAddressIp(const SocketAddressIp &src)
Copy constructor.
Definition: iosock.h:48
Reference and access existing string data.
Definition: substring.h:229
ulong writebin(const void *buf, ulong size)
Write binary output to stream.
Definition: iosock.h:1359
struct sockaddr addr
Generic address structure.
Definition: iosock.h:36
Base socket address.
Definition: sysio_sock.h:95
Shutdown output (writes) on socket.
Definition: sysio_sock.h:689
Function not supported/implemented.
Definition: sys.h:1121
Socket(Newline nl=NL_SYS, bool exceptions=1)
Constructor.
Definition: iosock.h:748
bool parse(const SubString &str, ushort port=0, int family=AF_UNSPEC)
Definition: iosock.h:216
bool listen_ip(ushort port, int family=AF_INET, int backlog=BACKLOG_DEFAULT)
Create and bind TCP socket on all interfaces and listen for connections.
Definition: iosock.h:921
SocketAddressUnix(struct sockaddr_un *ptr)
Constructor to copy from address.
Definition: iosock.h:538
const char * data() const
Get data pointer.
Generic socket address (used internally).
Definition: sysio_sock.h:113
Socket & set_timeout(ulong timeout_ms)
Set timeout for socket operations.
Definition: iosock.h:781
Unix Domain socket address (linux/unix).
Definition: iosock.h:515
static bool check(struct sockaddr *addr)
Check if address struct holds a supported IP address type.
Definition: iosock.h:498
ulong read(void *buf, ulong size, int flags=0, SocketAddressBase *address=NULL)
Read message from socket.
Definition: iosock.h:1324
bool format(String &str) const
Format IP address to given string (appended).
Definition: iosock.h:433
static void sysinit()
Initialize socket library.
Definition: iosock.h:1115