dyad
dyad copied to clipboard
Fail to get valid host ip address in Mac OS X 10.11.6
I modified the example echoserv.c a bit like this to get ip address:
...
static void onAccept(dyad_Event *e) {
printf("IP:%s\n",dyad_getAddress(e->remote));
dyad_addListener(e->remote, DYAD_EVENT_DATA, onData, NULL);
dyad_writef(e->remote, "echo server\r\n");
}
...
int main(void) {
dyad_Stream *s;
dyad_init();
s = dyad_newStream();
dyad_addListener(s, DYAD_EVENT_ERROR, onError, NULL);
dyad_addListener(s, DYAD_EVENT_ACCEPT, onAccept, NULL);
dyad_listen(s, 8000);
printf("IP:%s\n",dyad_getAddress(s));
while (dyad_getStreamCount() > 0) {
dyad_update();
}
return 0;
}
Finally I got the host ip address 0.0.0.0 which looks like invalid but the remote address is valid. The communication works well. Is it a bug concerned with OS or my incorrect practice of API?