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

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: Test that server socket cannot reuse port Created 7 years, 6 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..987bb978930c354a799da236fb6404f377431035 100644
--- a/net/socket/tcp_server_socket_unittest.cc
+++ b/net/socket/tcp_server_socket_unittest.cc
@@ -23,6 +23,7 @@ namespace net {
namespace {
const int kListenBacklog = 5;
+const int kListenPort = 31373;
class TCPServerSocketTest : public PlatformTest {
protected:
@@ -246,6 +247,24 @@ TEST_F(TCPServerSocketTest, AcceptIO) {
ASSERT_EQ(message, received_message);
}
+TEST_F(TCPServerSocketTest, Rebind) {
+ IPEndPoint address;
+ ParseAddress("127.0.0.1", kListenPort, &address);
wtc 2013/07/25 18:03:56 Using a constant listen port may prevent another p
Bei Zhang 2013/07/26 05:10:40 Done. I think no solution is perfect here. I canno
+
+ scoped_ptr<TCPServerSocket> socket(
+ new TCPServerSocket(NULL, NetLog::Source()));
+ ASSERT_EQ(OK, socket->Listen(address, kListenBacklog));
+
+ 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