The layer map in Java types — the four lines the exam question is really asking for
The layer map in Java types — the four lines the exam question is really asking for
Answer
// internet layer: an address, nothing more InetAddress host = InetAddress.getByName("example.org"); // transport layer: TCP and UDP endpoints Socket tcp = new Socket(host, 80); DatagramSocket udp = new DatagramSocket(); // application layer: naming and protocol URI page = URI.create("http://example.org/index.html");
Four types, three layers. `InetAddress` is the only internet-layer object Java hands you and it carries no data — it is an address. `Socket` and `DatagramSocket` are your two transport choices. `URI` (and `URLConnection`, module 4) name and drive an application protocol. There is deliberately no Java type for the host-to-network layer.
Harold 4e ch1 §The Layers of a Network; JDK javadoc java.net