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

Unified Diff: net/socket/tcp_socket_unittest.cc

Issue 879723002: When receiving OOB data on a socket, return ERR_OOB_DATA. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « net/socket/tcp_socket_libevent.cc ('k') | net/socket/tcp_socket_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_socket_unittest.cc
diff --git a/net/socket/tcp_socket_unittest.cc b/net/socket/tcp_socket_unittest.cc
index 4bfc1384fbd93101293d84fa43fcd92fb3ac8f67..2dec25620ff859a786d86ba2a3260b4c9137e35b 100644
--- a/net/socket/tcp_socket_unittest.cc
+++ b/net/socket/tcp_socket_unittest.cc
@@ -285,5 +285,42 @@ TEST_F(TCPSocketTest, ReadWrite) {
ASSERT_EQ(message, received_message);
}
+TEST_F(TCPSocketTest, ErrorOOBForTCPUrgentData) {
+ ASSERT_NO_FATAL_FAILURE(SetUpListenIPv4());
+
+ TestCompletionCallback connect_callback;
+ TCPSocket connecting_socket(NULL, NetLog::Source());
+ int result = connecting_socket.Open(ADDRESS_FAMILY_IPV4);
+ ASSERT_EQ(OK, result);
+ connecting_socket.Connect(local_address_, connect_callback.callback());
+
+ TestCompletionCallback accept_callback;
+ scoped_ptr<TCPSocket> accepted_socket;
+ IPEndPoint accepted_address;
+ result = socket_.Accept(&accepted_socket, &accepted_address,
+ accept_callback.callback());
+ ASSERT_EQ(OK, accept_callback.GetResult(result));
+
+ ASSERT_TRUE(accepted_socket.get());
+
+ // Both sockets should be on the loopback network interface.
+ EXPECT_EQ(accepted_address.address(), local_address_.address());
+
+ EXPECT_EQ(OK, connect_callback.WaitForResult());
+
+ // Send the TCP urgent data, which is a single byte of OOB data.
+ char byte = '@';
+ ssize_t sent = send(accepted_socket->socket(), &byte, sizeof(byte), MSG_OOB);
+ ASSERT_EQ(1, sent);
+
+ // Read the urgent data.
+ scoped_refptr<IOBufferWithSize> buffer(new IOBufferWithSize(8));
+ TestCompletionCallback read_callback;
+ result = connecting_socket.Read(buffer.get(), buffer->size(),
+ read_callback.callback());
+ EXPECT_EQ(ERR_OOB_DATA, result);
+ EXPECT_EQ(byte, buffer->data()[0]);
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/socket/tcp_socket_libevent.cc ('k') | net/socket/tcp_socket_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698