I've a conceptual question wrt the documentation (and perhaps implementation) of Poco StreamSockets and SocketImpl.
First of all my specific use case: A TCP client (proprietary app-layer protocol) running on a multi-interface host (several IPv4, several IPv6 addresses/interfaces) must contact a server. The client MUST use the right local interface (and optionally the right port). The application knows the right IPv4 address from cmd-line arguments.
Problem: The typical use of Poco StreamSocket is to create an instance of a StreamSocket and connect it to the server socket. No method to bind to a local interface. Going more into details reveals the StreamSocket::impl() method and the bind() method of the returned SocketImpl. But binding before connect results in a core dump (tried both, IPv4 address with port number zero=unspecified and IPv4 address with dedicated port) and bind after connect does not make much of a sense. System is Linux (Kubuntu 16.04) with default Poco dev libraries (1.58).
Reading through the documentation at http://pocoproject.org/docs/Poco.Net.So ... html#24524
reveals even in the latest release that "TCP clients should not bind a socket to a specific address." Why?
I guess there's a good reason, so before starting to debug the Poco libraries myself I'd like to find out what's behind this statement in SocketImpl. Can perhaps someone with insight comment on the background of this restriction? I consider the use case of "a client must use a specific local interface out of n available" to be a valid one. And TCP clients have ever since been able to bind to a specific interface. For Poco raw sockets and UDP sockets the client-side bind op works as expected.
Any straight-forward solution or experience on how to implement this for TCP? As next step I'd target TLS but that's another story...
thanks in advance,