import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
*
* @throws IOException
* in case of I/O error
+ * @throws UnknownHostException
+ * if the IP address of the host could not be determined
+ * @throws IllegalArgumentException
+ * if the port parameter is outside the specified range of valid
+ * port values, which is between 0 and 65535, inclusive
*/
public Server(int port, boolean ssl) throws IOException {
this((String) null, port, ssl);
*
* @throws IOException
* in case of I/O error
+ * @throws UnknownHostException
+ * if the IP address of the host could not be determined
+ * @throws IllegalArgumentException
+ * if the port parameter is outside the specified range of valid
+ * port values, which is between 0 and 65535, inclusive
*/
public Server(String name, int port, boolean ssl) throws IOException {
this.name = name;
}
try {
- tracer.trace(name + ": server starting on port " + port);
+ tracer.trace(name + ": server starting on port " + port + " ("
+ + (ssl ? "SSL" : "plain text") + ")");
while (started && !exiting) {
count(1);
}
}
}
+ }
- // only return when stopped
- while (started || exiting) {
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
+ // return only when stopped
+ while (started || exiting) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
}
}
}
*
* @throws IOException
* in case of I/O error
+ * @throws UnknownHostException
+ * if the host is not known
+ * @throws IllegalArgumentException
+ * if the port parameter is outside the specified range of valid
+ * port values, which is between 0 and 65535, inclusive
*/
static Socket createSocket(String host, int port, boolean ssl)
throws IOException {
Socket s;
if (ssl) {
s = SSLSocketFactory.getDefault().createSocket(host, port);
- ((SSLSocket) s).setEnabledCipherSuites(ANON_CIPHERS);
+ if (s instanceof SSLSocket) {
+ // Should always be the case
+ ((SSLSocket) s).setEnabledCipherSuites(ANON_CIPHERS);
+ }
} else {
s = new Socket(host, port);
}
*
* @throws IOException
* in case of I/O error
+ * @throws UnknownHostException
+ * if the IP address of the host could not be determined
+ * @throws IllegalArgumentException
+ * if the port parameter is outside the specified range of valid
+ * port values, which is between 0 and 65535, inclusive
*/
static ServerSocket createSocketServer(int port, boolean ssl)
throws IOException {
ServerSocket ss;
if (ssl) {
ss = SSLServerSocketFactory.getDefault().createServerSocket(port);
- ((SSLServerSocket) ss).setEnabledCipherSuites(ANON_CIPHERS);
+ if (ss instanceof SSLServerSocket) {
+ // Should always be the case
+ ((SSLServerSocket) ss).setEnabledCipherSuites(ANON_CIPHERS);
+ }
} else {
ss = new ServerSocket(port);
}