libcutils: remove unused socket_set_receive_timeout().
Test: treehugger
Change-Id: I834762fd83bdaa3b714c7531439bf9115a82e342
diff --git a/libcutils/include/cutils/sockets.h b/libcutils/include/cutils/sockets.h
index 285f150..be21a8f 100644
--- a/libcutils/include/cutils/sockets.h
+++ b/libcutils/include/cutils/sockets.h
@@ -103,14 +103,6 @@
int socket_close(cutils_socket_t sock);
/*
- * Sets socket receive timeout using SO_RCVTIMEO. Setting |timeout_ms| to 0
- * disables receive timeouts.
- *
- * Return 0 on success.
- */
-int socket_set_receive_timeout(cutils_socket_t sock, int timeout_ms);
-
-/*
* Returns the local port the socket is bound to or -1 on error.
*/
int socket_get_local_port(cutils_socket_t sock);
diff --git a/libcutils/sockets_test.cpp b/libcutils/sockets_test.cpp
index b762ac1..1fa40bc 100644
--- a/libcutils/sockets_test.cpp
+++ b/libcutils/sockets_test.cpp
@@ -73,25 +73,6 @@
EXPECT_EQ(0, socket_close(client));
}
-// Tests receive timeout. The timing verification logic must be very coarse to
-// make sure different systems can all pass these tests.
-void TestReceiveTimeout(cutils_socket_t sock) {
- time_t start_time;
- char buffer[32];
-
- // Make sure a 20ms timeout completes in 1 second or less.
- EXPECT_EQ(0, socket_set_receive_timeout(sock, 20));
- start_time = time(nullptr);
- EXPECT_EQ(-1, recv(sock, buffer, sizeof(buffer), 0));
- EXPECT_LE(difftime(time(nullptr), start_time), 1.0);
-
- // Make sure a 1250ms timeout takes 1 second or more.
- EXPECT_EQ(0, socket_set_receive_timeout(sock, 1250));
- start_time = time(nullptr);
- EXPECT_EQ(-1, recv(sock, buffer, sizeof(buffer), 0));
- EXPECT_LE(1.0, difftime(time(nullptr), start_time));
-}
-
// Tests socket_get_local_port().
TEST(SocketsTest, TestGetLocalPort) {
cutils_socket_t server;
@@ -157,32 +138,6 @@
TestConnectedSockets(handler, client, SOCK_STREAM);
}
-// Tests setting a receive timeout for UDP sockets.
-TEST(SocketsTest, TestUdpReceiveTimeout) {
- cutils_socket_t sock = socket_inaddr_any_server(0, SOCK_DGRAM);
- ASSERT_NE(INVALID_SOCKET, sock);
-
- TestReceiveTimeout(sock);
-
- EXPECT_EQ(0, socket_close(sock));
-}
-
-// Tests setting a receive timeout for TCP sockets.
-TEST(SocketsTest, TestTcpReceiveTimeout) {
- cutils_socket_t server = socket_inaddr_any_server(0, SOCK_STREAM);
- ASSERT_NE(INVALID_SOCKET, server);
-
- cutils_socket_t client = socket_network_client(
- "localhost", socket_get_local_port(server), SOCK_STREAM);
- cutils_socket_t handler = accept(server, nullptr, nullptr);
- EXPECT_EQ(0, socket_close(server));
-
- TestReceiveTimeout(handler);
-
- EXPECT_EQ(0, socket_close(client));
- EXPECT_EQ(0, socket_close(handler));
-}
-
// Tests socket_send_buffers() failure.
TEST(SocketsTest, TestSocketSendBuffersFailure) {
EXPECT_EQ(-1, socket_send_buffers(INVALID_SOCKET, nullptr, 0));
diff --git a/libcutils/sockets_unix.cpp b/libcutils/sockets_unix.cpp
index 6acdcd8..84663e6 100644
--- a/libcutils/sockets_unix.cpp
+++ b/libcutils/sockets_unix.cpp
@@ -31,13 +31,6 @@
return close(sock);
}
-int socket_set_receive_timeout(cutils_socket_t sock, int timeout_ms) {
- timeval tv;
- tv.tv_sec = timeout_ms / 1000;
- tv.tv_usec = (timeout_ms % 1000) * 1000;
- return setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
-}
-
ssize_t socket_send_buffers(cutils_socket_t sock,
const cutils_socket_buffer_t* buffers,
size_t num_buffers) {
diff --git a/libcutils/sockets_windows.cpp b/libcutils/sockets_windows.cpp
index df14712..4adb796 100644
--- a/libcutils/sockets_windows.cpp
+++ b/libcutils/sockets_windows.cpp
@@ -54,11 +54,6 @@
return closesocket(sock);
}
-int socket_set_receive_timeout(cutils_socket_t sock, int timeout_ms) {
- return setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
- reinterpret_cast<char*>(&timeout_ms), sizeof(timeout_ms));
-}
-
ssize_t socket_send_buffers(cutils_socket_t sock,
const cutils_socket_buffer_t* buffers,
size_t num_buffers) {