port = 80;
}
try {
socket = new Socket(host, port);
} catch (UnknownHostException uhe) {
throw new WebSocketException("unknown host: " + host, uhe);
} catch (IOException ioe) {
throw new WebSocketException("error while creating socket to " + url, ioe);
}
} else if (scheme != null && scheme.equals("wss")) {
if (port == -1) {
port = 443;
}
try {
SocketFactory factory = SSLSocketFactory.getDefault();
socket = factory.createSocket(host, port);
} catch (UnknownHostException uhe) {
throw new WebSocketException("unknown host: " + host, uhe);
} catch (IOException ioe) {
throw new WebSocketException("error while creating secure socket to " + url, ioe);
}
} else {
throw new WebSocketException("unsupported protocol: " + scheme);
}
return socket;
}