Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Unified Diff: net/socket/tcp_server_socket_unittest.cc

Issue 18683002: Test that server socket cannot reuse port (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_server_socket_unittest.cc
diff --git a/net/socket/tcp_server_socket_unittest.cc b/net/socket/tcp_server_socket_unittest.cc
index fd81e550d080579f2b623e410b5622229db0bfd8..d95e6acf484ee6da9535aa54268957446ee95e58 100644
--- a/net/socket/tcp_server_socket_unittest.cc
+++ b/net/socket/tcp_server_socket_unittest.cc
@@ -246,6 +246,28 @@ TEST_F(TCPServerSocketTest, AcceptIO) {
ASSERT_EQ(message, received_message);
}
+TEST_F(TCPServerSocketTest, Rebind) {
+ IPEndPoint address;
+ // Bind to a random, unused port.
+ ParseAddress("127.0.0.1", 0, &address);
+
+ scoped_ptr<TCPServerSocket> socket(
+ new TCPServerSocket(NULL, NetLog::Source()));
+ ASSERT_EQ(OK, socket->Listen(address, kListenBacklog));
+
+ // Retrieve the real endpoint bound.
+ ASSERT_EQ(OK, socket->GetLocalAddress(&address));
+
+ scoped_ptr<TCPServerSocket> conflict_socket(
+ new TCPServerSocket(NULL, NetLog::Source()));
+ ASSERT_NE(OK, conflict_socket->Listen(address, kListenBacklog));
+
+ // Unbind.
+ socket.reset(NULL);
+
+ ASSERT_EQ(OK, conflict_socket->Listen(address, kListenBacklog));
+}
+
} // namespace
} // namespace net
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698