Hint that the port is numeric when binding an AsyncServerSocket
authorChristopher Dykes <cdykes@fb.com>
Wed, 16 Nov 2016 21:19:59 +0000 (13:19 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Wed, 16 Nov 2016 21:24:54 +0000 (13:24 -0800)
Summary: Because it had better be numeric or something is very wrong.

Reviewed By: yfeldblum

Differential Revision: D4190568

fbshipit-source-id: 52a5ebfcedb545201191fc48f66a4419eee8f748

folly/io/async/AsyncServerSocket.cpp

index e163da68379c1dd9026c69818266aff6f648ebeb..65d4c5c48af4a9549121eefcc7b90e51040ce691 100644 (file)
@@ -367,7 +367,7 @@ void AsyncServerSocket::bind(uint16_t port) {
   memset(&hints, 0, sizeof(hints));
   hints.ai_family = AF_UNSPEC;
   hints.ai_socktype = SOCK_STREAM;
-  hints.ai_flags = AI_PASSIVE;
+  hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV;
   snprintf(sport, sizeof(sport), "%u", port);
 
   if (getaddrinfo(nullptr, sport, &hints, &res0)) {