summaryrefslogtreecommitdiff
path: root/implementation/endpoints/src/udp_client_endpoint_impl.cpp
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2020-12-04 11:52:58 +0100
committerLutz Bichler <Lutz.Bichler@bmw.de>2020-12-04 11:52:58 +0100
commit0f51130b96b5400b87924d8705d0e4a77930cb61 (patch)
tree0dade462d83a9b4d1de6eb82ab0827d5ec7e93cf /implementation/endpoints/src/udp_client_endpoint_impl.cpp
parent710a8613ee5bd9eb490addecd7f2ee8049c4fd0c (diff)
downloadvSomeIP-0f51130b96b5400b87924d8705d0e4a77930cb61.tar.gz
vsomeip 3.1.20.23.1.20.2
Diffstat (limited to 'implementation/endpoints/src/udp_client_endpoint_impl.cpp')
-rw-r--r--implementation/endpoints/src/udp_client_endpoint_impl.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp
index ff24173..dc7a7bf 100644
--- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp
@@ -84,11 +84,6 @@ void udp_client_endpoint_impl::connect() {
}
}
- if (local_.port() == ILLEGAL_PORT) {
- // Let the OS assign the port
- local_.port(0);
- }
-
#ifndef _WIN32
// If specified, bind to device
std::string its_device(configuration_->get_device());
@@ -100,25 +95,22 @@ void udp_client_endpoint_impl::connect() {
}
#endif
- // In case a client endpoint port was configured,
- // bind to it before connecting
- if (local_.port() != ILLEGAL_PORT) {
- boost::system::error_code its_bind_error;
- socket_->bind(local_, its_bind_error);
- if(its_bind_error) {
- VSOMEIP_WARNING << "udp_client_endpoint::connect: "
- "Error binding socket: " << its_bind_error.message()
- << " remote:" << get_address_port_remote();
- try {
- // don't connect on bind error to avoid using a random port
- strand_.post(std::bind(&client_endpoint_impl::connect_cbk,
- shared_from_this(), its_bind_error));
- } catch (const std::exception &e) {
- VSOMEIP_ERROR << "udp_client_endpoint_impl::connect: "
- << e.what() << " remote:" << get_address_port_remote();
- }
- return;
+ // Bind address and, optionally, port.
+ boost::system::error_code its_bind_error;
+ socket_->bind(local_, its_bind_error);
+ if(its_bind_error) {
+ VSOMEIP_WARNING << "udp_client_endpoint::connect: "
+ "Error binding socket: " << its_bind_error.message()
+ << " remote:" << get_address_port_remote();
+ try {
+ // don't connect on bind error to avoid using a random port
+ strand_.post(std::bind(&client_endpoint_impl::connect_cbk,
+ shared_from_this(), its_bind_error));
+ } catch (const std::exception &e) {
+ VSOMEIP_ERROR << "udp_client_endpoint_impl::connect: "
+ << e.what() << " remote:" << get_address_port_remote();
}
+ return;
}
state_ = cei_state_e::CONNECTING;