Last change
on this file since 388 was 388, checked in by coas-nagasima, 5 years ago |
Azure IoT Hub Device C SDK を使ったサンプルの追加
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Id
-
Property svn:mime-type
set to
text/x-csrc
|
File size:
479 bytes
|
Rev | Line | |
---|
[388] | 1 | #define _GNU_SOURCE
|
---|
| 2 |
|
---|
| 3 | #include <sys/socket.h>
|
---|
| 4 | #include <netdb.h>
|
---|
| 5 | #include <errno.h>
|
---|
| 6 | #include <stdlib.h>
|
---|
| 7 |
|
---|
| 8 | struct hostent *gethostbyname2(const char *name, int af)
|
---|
| 9 | {
|
---|
| 10 | static struct hostent *h;
|
---|
| 11 | size_t size = 63;
|
---|
| 12 | struct hostent *res;
|
---|
| 13 | int err;
|
---|
| 14 | do {
|
---|
| 15 | free(h);
|
---|
| 16 | h = malloc(size+=size+1);
|
---|
| 17 | if (!h) {
|
---|
| 18 | h_errno = NO_RECOVERY;
|
---|
| 19 | return 0;
|
---|
| 20 | }
|
---|
| 21 | err = gethostbyname2_r(name, af, h,
|
---|
| 22 | (void *)(h+1), size-sizeof *h, &res, &h_errno);
|
---|
| 23 | } while (err == ERANGE);
|
---|
| 24 | return err ? 0 : h;
|
---|
| 25 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.