diff --git a/starboard/nplb/socket_get_interface_address_test.cc b/starboard/nplb/socket_get_interface_address_test.cc index 3f1c145cd56d..0176c4a167df 100644 --- a/starboard/nplb/socket_get_interface_address_test.cc +++ b/starboard/nplb/socket_get_interface_address_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 17 + #include "starboard/common/socket.h" #include "starboard/nplb/socket_helpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -184,3 +186,4 @@ INSTANTIATE_TEST_CASE_P(SbSocketAddressTypes, } // namespace } // namespace nplb } // namespace starboard +#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/socket_get_local_address_test.cc b/starboard/nplb/socket_get_local_address_test.cc index 38954f93c833..50c867fbee4b 100644 --- a/starboard/nplb/socket_get_local_address_test.cc +++ b/starboard/nplb/socket_get_local_address_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 17 + #include #include "starboard/common/socket.h" @@ -140,3 +142,5 @@ INSTANTIATE_TEST_CASE_P( } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/socket_helpers.cc b/starboard/nplb/socket_helpers.cc index 3efccdbd5af9..603efeab8857 100644 --- a/starboard/nplb/socket_helpers.cc +++ b/starboard/nplb/socket_helpers.cc @@ -68,35 +68,6 @@ int GetPortNumberForTests() { #endif } -bool IsUnspecified(const SbSocketAddress* address) { - // Look at each piece of memory and make sure too many of them aren't zero. - int components = (address->type == kSbSocketAddressTypeIpv4 ? 4 : 16); - int zero_count = 0; - for (int i = 0; i < components; ++i) { - if (address->address[i] == 0) { - ++zero_count; - } - } - return components == zero_count; -} - -bool IsLocalhost(const SbSocketAddress* address) { - if (address->type == kSbSocketAddressTypeIpv4) { - return address->address[0] == 127; - } - - if (address->type == kSbSocketAddressTypeIpv6) { - bool may_be_localhost = true; - for (int i = 0; i < 15; ++i) { - may_be_localhost &= (address->address[i] == 0); - } - - return (may_be_localhost && address->address[15] == 1); - } - - return false; -} - SbSocket CreateServerTcpSocket(SbSocketAddressType address_type) { SbSocket server_socket = SbSocketCreate(address_type, kSbSocketProtocolTcp); if (!SbSocketIsValid(server_socket)) { @@ -146,78 +117,6 @@ SbSocket CreateListeningTcpSocket(SbSocketAddressType address_type, int port) { return server_socket; } -int Transfer(SbSocket receive_socket, - char* out_data, - SbSocket send_socket, - const char* send_data, - int size) { - int send_total = 0; - int receive_total = 0; - while (receive_total < size) { - if (send_total < size) { - int bytes_sent = SbSocketSendTo(send_socket, send_data + send_total, - size - send_total, NULL); - if (bytes_sent < 0) { - if (SbSocketGetLastError(send_socket) != kSbSocketPending) { - return -1; - } - bytes_sent = 0; - } - - send_total += bytes_sent; - } - - int bytes_received = SbSocketReceiveFrom( - receive_socket, out_data + receive_total, size - receive_total, NULL); - if (bytes_received < 0) { - if (SbSocketGetLastError(receive_socket) != kSbSocketPending) { - return -1; - } - bytes_received = 0; - } - - receive_total += bytes_received; - } - - return size; -} - -int Transfer(Socket* receive_socket, - char* out_data, - Socket* send_socket, - const char* send_data, - int size) { - int send_total = 0; - int receive_total = 0; - while (receive_total < size) { - if (send_total < size) { - int bytes_sent = - send_socket->SendTo(send_data + send_total, size - send_total, NULL); - if (bytes_sent < 0) { - if (!send_socket->IsPending()) { - return -1; - } - bytes_sent = 0; - } - - send_total += bytes_sent; - } - - int bytes_received = receive_socket->ReceiveFrom( - out_data + receive_total, size - receive_total, NULL); - if (bytes_received < 0) { - if (!receive_socket->IsPending()) { - return -1; - } - bytes_received = 0; - } - - receive_total += bytes_received; - } - - return size; -} - int64_t TimedWait(SbSocketWaiter waiter) { int64_t start = CurrentMonotonicTime(); SbSocketWaiterWait(waiter); diff --git a/starboard/nplb/socket_helpers.h b/starboard/nplb/socket_helpers.h index 06e5c4e807aa..783cb68e13dc 100644 --- a/starboard/nplb/socket_helpers.h +++ b/starboard/nplb/socket_helpers.h @@ -29,14 +29,6 @@ namespace nplb { const int64_t kSocketTimeout = 200'000; // 200ms -// Returns true if the given address is the unspecified address (all zeros), -// supporting both address types. -bool IsUnspecified(const SbSocketAddress* address); - -// Returns true if the given address is the localhost address, supporting both -// address types. -bool IsLocalhost(const SbSocketAddress* address); - // Returns a valid port number that can be bound to for use in nplb tests. // This will always return the same port number. int GetPortNumberForTests(); @@ -50,19 +42,6 @@ SbSocket CreateBoundTcpSocket(SbSocketAddressType address_type, int port); // Creates a TCP/IP socket listening on all interfaces on the given port. SbSocket CreateListeningTcpSocket(SbSocketAddressType address_type, int port); -// Transfers data between the two connected local sockets, spinning until |size| -// has been transferred, or an error occurs. -int Transfer(SbSocket receive_socket, - char* out_data, - SbSocket send_socket, - const char* send_data, - int size); -int Transfer(Socket* receive_socket, - char* out_data, - Socket* send_socket, - const char* send_data, - int size); - // Waits on the given waiter, and returns the elapsed time in microseconds. int64_t TimedWait(SbSocketWaiter waiter);