Fix copyright lines
[folly.git] / folly / io / async / test / AsyncSocketTest.cpp
index c339feff4dad3d66dbeced2e1e75deba09785ad0..12a248450f08291b75464b3bae1d2bbcc50ea519 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2014-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 #include <iostream>
 
-#include <folly/io/async/AsyncSocket.h>
 #include <folly/io/async/AsyncServerSocket.h>
+#include <folly/io/async/AsyncSocket.h>
 #include <folly/io/async/EventBase.h>
-
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
 
 namespace folly {
 
@@ -76,4 +75,17 @@ TEST(AsyncSocketTest, v4v6samePort) {
   }
 }
 
-} // namespace
+TEST(AsyncSocketTest, duplicateBind) {
+  EventBase base;
+  auto server1 = AsyncServerSocket::newSocket(&base);
+  server1->bind(0);
+  server1->listen(10);
+
+  SocketAddress address;
+  server1->getAddress(std::addressof(address));
+
+  auto server2 = AsyncServerSocket::newSocket(&base);
+  EXPECT_THROW(server2->bind(address.getPort()), std::exception);
+}
+
+} // namespace folly