diff options
author | ikarienator@chromium.org <ikarienator@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-02 08:30:17 +0000 |
---|---|---|
committer | ikarienator@chromium.org <ikarienator@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-02 08:30:17 +0000 |
commit | 6f2408debccfe387f6c453e31f5f1c74da2f8f64 (patch) | |
tree | 6cb42c9e14a80e70da6377aea1173f7fc1a23dfa | |
parent | 30a90f9a8573204b89a98577228207cf4153cad0 (diff) | |
download | chromium_src-6f2408debccfe387f6c453e31f5f1c74da2f8f64.zip chromium_src-6f2408debccfe387f6c453e31f5f1c74da2f8f64.tar.gz chromium_src-6f2408debccfe387f6c453e31f5f1c74da2f8f64.tar.bz2 |
After removing allowReuseAddress and always setting SO_REUSEADDR, we need a test to ensure that the ports are not reused on *nix systems.
BUG=173533
Review URL: https://chromiumcodereview.appspot.com/18683002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215242 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/socket/tcp_server_socket_unittest.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/socket/tcp_server_socket_unittest.cc b/net/socket/tcp_server_socket_unittest.cc index fd81e55..d95e6ac 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 |