| 664 | |
| 665 | template<typename Protocol> |
| 666 | void client_endpoint_impl<Protocol>::close_socket_unlocked(bool _recreate_socket) { |
| 667 | |
| 668 | if (socket_->is_open()) { |
| 669 | #if defined(__linux__) || defined(__QNX__) |
| 670 | if (!socket_->can_read_fd_flags()) { |
| 671 | VSOMEIP_ERROR_P << "Socket/handle closed already, errno " << errno << ", " << get_remote_information() << " endpoint > " |
| 672 | << this; |
| 673 | } |
| 674 | #endif |
| 675 | |
| 676 | // NOTE: no `shutdown`, as it will cause a TCP FIN if the underlying protocol is TCP, whereas we want |
| 677 | // only TCP RSTs (and therefore configure SO_LINGER accordingly) |
| 678 | boost::system::error_code its_error; |
| 679 | socket_->close(its_error); |
| 680 | if (its_error) { |
| 681 | VSOMEIP_WARNING_P << "Socket close error, (" << its_error.value() << "): " << its_error.message() |
| 682 | << ", remote: " << get_remote_information() << ", endpoint > " << this << " socket state > " |
| 683 | << to_string(state_.load()); |
| 684 | } |
| 685 | } else { |
| 686 | VSOMEIP_WARNING_P << "Socket was not open, remote: " << get_remote_information() << ", endpoint > " << this << " socket state > " |
| 687 | << to_string(state_.load()); |
| 688 | } |
| 689 | |
| 690 | state_ = cei_state_e::CLOSED; |
| 691 | |
| 692 | if (_recreate_socket) { |
| 693 | recreate_socket(); |
| 694 | VSOMEIP_WARNING_P << "Socket has been reset, remote: " << get_remote_information() << ", endpoint > " << this << " socket state > " |
| 695 | << to_string(state_.load()); |
| 696 | } else { |
| 697 | VSOMEIP_INFO_P << "Not recreating socket, remote: " << get_remote_information() << ", endpoint > " << this << " socket state > " |
| 698 | << to_string(state_.load()); |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | template<typename Protocol> |
| 703 | bool client_endpoint_impl<Protocol>::get_remote_address(boost::asio::ip::address& _address) const { |