Skip to content

Commit

Permalink
tinysvcmdns: ensure name is advertised with .local suffix
Browse files Browse the repository at this point in the history
Fixes operation with iOS 7.
  • Loading branch information
abrasive committed Jun 24, 2014
1 parent b55e75a commit 2c4031f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mdns_tinysvcmdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ static int mdns_tinysvcmdns_register(char *apname, int port) {
return -1;
}

char hostname[100];
gethostname(hostname, 100);
// room for name + .local + NULL
char hostname[100 + 6];
gethostname(hostname, 99);
// according to POSIX, this may be truncated without a final NULL !
hostname[99] = 0;

// will not work on iOS if the hostname doesn't end in .local
strcat(hostname, ".local");

if (getifaddrs(&ifalist) < 0)
{
Expand Down

0 comments on commit 2c4031f

Please sign in to comment.