Dear Poco contributors and maintainers,
following the discussion in the support forum (thread viewtopic.php?f=12&t=6774) here's the request for the wish list:
I'd love Poco to provide a bind operation for TCP client sockets.
Trying to bind to a local address using the StreamSocket's SocketImpl results in core dumps - the doc expclicitly warns about this configuration: http://pocoproject.org/docs/Poco.Net.So ... html#24524 : "TCP clients should not bind a socket to a specific address". But there are good reasons for TCP clients binding to a local interface.
Client socket binding to addresses or ports (v4, v6) is needed and useful whenever a system has more than one network interface and an application MUST use one particular of these. The BSD socket interface supports this kind of client socket binding for good reasons, and Poco should support it for TCP sockets, too (for UDP sockets it's already implemented and working).
Particular use case: A device has active WiFi and 3G interfaces. The default route is set to WiFi. Measurements and OAM must measure the performance of the 3G link towards one specific reflecting node and monitor its availability (e.g., send keep-alives). Without explicit client socket binding there's no way how this can be achieved. Moreover, even explicit routing does not help if there's one single destination node (IP) shared for WiFi and 3G monitoring. Alternative use case is when the client needs to use a specific local port because of local policies.
I've not gone into the implementation details but I suspect that StreamSocket does a late instantiation of the underlying SocketImpl at connect()-time. An early instantiation (dedicated constructor for local address) may or may not be sufficient. As written above, for UDP it works as expected.
Thanks in advance