Last change
on this file since 413 was 398, checked in by coas-nagasima, 5 years ago |
mbedTLS版Azure IoT Hub接続サンプルのソースコードを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
463 bytes
|
Line | |
---|
1 | #define _GNU_SOURCE
|
---|
2 |
|
---|
3 | #include <netdb.h>
|
---|
4 | #include <errno.h>
|
---|
5 | #include <stdlib.h>
|
---|
6 |
|
---|
7 | struct hostent *gethostbyaddr(const void *a, socklen_t l, int af)
|
---|
8 | {
|
---|
9 | static struct hostent *h;
|
---|
10 | size_t size = 63;
|
---|
11 | struct hostent *res;
|
---|
12 | int err;
|
---|
13 | do {
|
---|
14 | free(h);
|
---|
15 | h = malloc(size+=size+1);
|
---|
16 | if (!h) {
|
---|
17 | h_errno = NO_RECOVERY;
|
---|
18 | return 0;
|
---|
19 | }
|
---|
20 | err = gethostbyaddr_r(a, l, af, h,
|
---|
21 | (void *)(h+1), size-sizeof *h, &res, &h_errno);
|
---|
22 | } while (err == ERANGE);
|
---|
23 | return err ? 0 : h;
|
---|
24 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.