Skip to content

Commit

Permalink
std.socket: Require hostname when using getnameinfo, for consistency …
Browse files Browse the repository at this point in the history
…with gethostbyaddr
  • Loading branch information
CyberShadow committed Sep 5, 2011
1 parent eb7d8d9 commit 3cc1436
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions std/c/windows/winsock.d
Expand Up @@ -68,6 +68,16 @@ protoent* getprotobyname(const char* name);
protoent* getprotobynumber(int number);
servent* getservbyname(const char* name, const char* proto);
servent* getservbyport(int port, const char* proto);

enum: int
{
NI_NOFQDN = 0x01,
NI_NUMERICHOST = 0x02,
NI_NAMEREQD = 0x04,
NI_NUMERICSERV = 0x08,
NI_DGRAM = 0x10,
}

int gethostname(const char* name, int namelen);
int getaddrinfo(const(char)* nodename, const(char)* servname, const(addrinfo)* hints, addrinfo** res);
void freeaddrinfo(addrinfo* ai);
Expand Down
2 changes: 1 addition & 1 deletion std/socket.d
Expand Up @@ -780,7 +780,7 @@ abstract class Address
enforce(getnameinfoPointer(
name(), nameLen(),
buf.ptr, cast(uint)buf.length,
null, 0, 0
null, 0, NI_NAMEREQD
) == 0, new AddressException("Could not get host name"));
return assumeUnique(buf[0 .. strlen(buf.ptr)]);
}
Expand Down

0 comments on commit 3cc1436

Please sign in to comment.