* @param proxy The proxy
* @return The socket
*/
public Socket createSocket(Proxy proxy) {
if (userFactory instanceof SocketFactory) {
SocketFactory userFactory = (SocketFactory) this.userFactory;
return new TimedSocketWrapper(userFactory.createSocket(proxy));
} else if (proxy == Proxy.NO_PROXY) {
try {
return createSocket();
} catch (IOException e) {
throw new RuntimeException(
"Empty create socket returns IOException!" +
e.getMessage(), e);
}
} else {
throw new UnsupportedOperationException(
userFactory.getClass().getName() +
" does not support creating a socket through a proxy." +
proxy.type() + ", " + proxy.address());
}