Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.
This repository was archived by the owner on May 27, 2021. It is now read-only.

Fail to get valid host ip address in Mac OS X 10.11.6 #18

@eeyrw

Description

@eeyrw

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions