forked from BruceEckel/OnJava8-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSimpleServer.java
More file actions
28 lines (27 loc) · 801 Bytes
/
Copy pathTestSimpleServer.java
File metadata and controls
28 lines (27 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// network/TestSimpleServer.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import java.io.*;
import java.net.*;
import java.util.concurrent.*;
import onjava.Nap;
public class TestSimpleServer {
// Choose a port outside of the range 1-1024:
public static final int port = 8080;
public static void main(String[] args) {
try (
ServerSocket ss =
new ServerSocket(port)
) {
CompletableFuture.runAsync(
new SimpleServer(ss));
CompletableFuture.runAsync(
new SimpleClient(Local.host(), port));
new Nap(1);
// Success if no exceptions happen
} catch(IOException e) {
throw new RuntimeException(e);
}
}
}