Closed suzukieng closed 7 years ago
Some background info: I'm working on a project where I'm overriding the default Socket implementation and tunnel the Socket traffic through another communication channel.
The rationale behind not using a SocketFactory (and providing it in the ctor of NetworkDataSource) is that with the override approach we can also inject a custom DatagramSocket. For some weird reason javax.net has a SocketFactory but no DatagramSocketFactory. Other libraries such as Apache Commons provide their own factory classes (see: https://commons.apache.org/proper/commons-net/javadocs/api-1.4.1/org/apache/commons/net/DatagramSocketFactory.html) but I opted for the override approach to keep things simple, and not extend the API for a feature that will probably be seldomly used.
Looks sensible. Could you squash the commits?
@Flowdalic Sure, done.
Thanks a lot @Flowdalic for the lightning-quick merge.
If you're wondering why I asked for this, see: https://blog.classycode.com/sockets-over-nfc-on-android-c294b6c58bbf
It is often useful to be able to inject a non-default Socket instance via an override or a SocketFactory for testing purposes, or to provide a custom implementation.