20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 import java.io.IOException; |
24 import java.io.IOException; |
|
25 import java.net.SocketException; |
25 import java.net.URI; |
26 import java.net.URI; |
26 import java.util.concurrent.CompletableFuture; |
27 import java.util.concurrent.CompletableFuture; |
27 import javax.net.ssl.SSLContext; |
28 import javax.net.ssl.SSLContext; |
28 import javax.net.ServerSocketFactory; |
29 import javax.net.ServerSocketFactory; |
29 import javax.net.ssl.SSLServerSocketFactory; |
30 import javax.net.ssl.SSLServerSocketFactory; |
217 try { |
218 try { |
218 int len = s.length(); |
219 int len = s.length(); |
219 out.println("Server: going to send [" + s + "]"); |
220 out.println("Server: going to send [" + s + "]"); |
220 for (int i = 0; i < len; i++) { |
221 for (int i = 0; i < len; i++) { |
221 String onechar = s.substring(i, i + 1); |
222 String onechar = s.substring(i, i + 1); |
222 conn.send(onechar); |
223 try { |
|
224 conn.send(onechar); |
|
225 } catch(SocketException x) { |
|
226 if (!useSSL || i != len - 1) throw x; |
|
227 if (x.getMessage().contains("closed by remote host")) { |
|
228 String osname = System.getProperty("os.name", "unknown"); |
|
229 // On Solaris we can receive an exception when |
|
230 // the client closes the connection after receiving |
|
231 // the last expected char. |
|
232 if (osname.contains("SunO")) { |
|
233 System.out.println(osname + " detected"); |
|
234 System.out.println("WARNING: ignoring " + x); |
|
235 System.err.println(osname + " detected"); |
|
236 System.err.println("WARNING: ignoring " + x); |
|
237 } |
|
238 } |
|
239 } |
223 Thread.sleep(10); |
240 Thread.sleep(10); |
224 } |
241 } |
225 out.println("Server: sent [" + s + "]"); |
242 out.println("Server: sent [" + s + "]"); |
226 } catch (IOException | InterruptedException e) { |
243 } catch (IOException | InterruptedException e) { |
227 throw new RuntimeException(e); |
244 throw new RuntimeException(e); |