socket_util.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "remoting/protocol/socket_util.h"
  5. #include "net/base/net_errors.h"
  6. namespace remoting {
  7. SocketErrorAction GetSocketErrorAction(int error) {
  8. switch (error) {
  9. // UDP is connectionless, so we may receive ICMP unreachable or reset errors
  10. // for previous sends to different addresses.
  11. case net::ERR_ADDRESS_UNREACHABLE:
  12. case net::ERR_CONNECTION_RESET:
  13. return SOCKET_ERROR_ACTION_RETRY;
  14. // Target address is invalid. The socket is still usable for different
  15. // target addresses and the error can be ignored.
  16. case net::ERR_ADDRESS_INVALID:
  17. return SOCKET_ERROR_ACTION_IGNORE;
  18. // May be returned when the packet is blocked by local firewall (see
  19. // https://code.google.com/p/webrtc/issues/detail?id=1207). The firewall may
  20. // still allow us to send to other addresses, so ignore the error for this
  21. // particular send.
  22. case net::ERR_ACCESS_DENIED:
  23. return SOCKET_ERROR_ACTION_IGNORE;
  24. // Indicates that the buffer in the network adapter is full, so drop this
  25. // packet and assume the socket is still usable.
  26. case net::ERR_OUT_OF_MEMORY:
  27. return SOCKET_ERROR_ACTION_IGNORE;
  28. default:
  29. return SOCKET_ERROR_ACTION_FAIL;
  30. }
  31. }
  32. } // namespace remoting