Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Java Session 4 New York University School of Continuing and Professional Studies.

Similar presentations


Presentation on theme: "Advanced Java Session 4 New York University School of Continuing and Professional Studies."— Presentation transcript:

1 Advanced Java Session 4 New York University School of Continuing and Professional Studies

2 2 Objectives Networking Basics –Topologies, Layers, Communications Command line tools Network programming basics –Sockets, TCP/IP stack Java Network Programming –Creating sockets –Implementing servers –URLs and URLConnections –Protocol Handlers –Content Handlers Advanced concepts in Sockets –Secure Sockets – Client and Server –Channels (Non-Blocking I/O) –UDP_ Datagrams and Sockets –Multicast Sockets

3 3 Bus

4 4 Star

5 5 Sample Network

6 6 ISO stack and TCP/IP stack Application Presentation Session Transport Network Data Link Physical Application Transport (TCP & UDP) Internet (IP) Network Interface ISO Reference Model TCP Reference Model

7 7 Network Communications Application Transport Internet Network Interface Application Transport Internet Network Interface Machine AMachine B Packets

8 8 TCP/IP stack

9 9 IP Java supports only IP based networks IP (Internet Protocol) has a number of advantages over competing protocols such as AppleTalk and IPX etc. Robust (multiple routes between any 2 points) Cross platform

10 10 TCP Layered on top of IP Guaranteed delivery of packets “in the order in which they were sent” Carries a fair amount of overhead

11 11 UDP Layered on top of IP Unreliable No guarantee that packets will arrive at the destination or even arrive at all

12 12 IP Addresses Every Computer is identified by a 4 byte (IPV4) number (e.g. 66.95.177.137 ) Slow transition to IPV6 is underway which uses a 16 byte number for addresses (since JDK 1.4) NAT and IP Masquerading allow reuse of same IP addresses in networks separated by a router/firewall

13 13 Multicasting Middle ground between “unicasting” (point- to-point) and “broadcasting” (to-everybody) Address range between 224.0.0.0 (reserved) to 239.255.255.255

14 14 Domain Name System Top Level Domains – com, net, org, … are served by “ROOT” dns servers run by InterNic All domains must be registered with Internic Delegate model is used to allow organizations to control their own set of names

15 15 Sockets and Ports Source ip Source port Destination ip Destination port

16 16 TCP/IP Session Source machine creates a socket and attempts to connect to a destination machine by giving its “ip” and “port” numbers Source machine responds with ConnectionAccepted If the destination machine is listening on that port “and” accepts this connection it responds with “request accepted” Data can now be transferred until an EOF is seen or a Network Error occurs

17 17 Some Useful Commands telnet - connects to given host and port netstat – shows status of TCP/IP activity nslookup – used to look up IP Addresses of host names

18 18 Examples SocketTest.java –Simple socket client EchoServer.java –Simple Socket Server

19 19 Examples ThreadedEchoServer.java –Multithreaded Socket Server –Can service multiple clients

20 20 The java.net package Contains classes and interfaces that can be used to write network programs in Java InetAddress, Inet4Address and Inet6Address NetworkInterface class SocketImpl class SocketAddress (abstract) and InetSocketAddress (implements Serializable) Socket, ServerSocket, DatagramSocket URL, URLConnection, HttpURLConnection

21 21 The javax.net and javax.net.ssl packages Contains classes and interfaces that can be used to create SSL Sockets SocketFactory, ServerSocketFactory in javax.net SSLSocketFactory, SSLServerSocketFactory in javax.net.ssl SSLSocket, SSLServerSocket HttpsURLConnection

22 22 java.nio and java.nio.channels Data Buffers for storing and manipulating raw data before and after I/O Channels for reading and writing from entities that are capable of performing I/O such as files, devices and sockets

23 23 More Examples HostLookup.java InterfaceLister.java PortScanner.java (uses socket factory) ChargenServer.java and ChargenClient.java (demonstrate SocketChannel and non-blocking operations on sockets)

24 24 UDP Examples UDPServer.java and UDPEchoServer.java UDPClient.java

25 25 Multicast Examples MulticastSniffer.java MulticastSender.java

26 26 URLConnection examples AllHeaders.java HttpGetter.java FormPoster.java

27 27 Java Mail API SMTPClient.java SMTPApplet.java

28 28 Network Security and Applets Can’t connect to servers other than the one it was downloaded from. Can’t access local hard disk Signed applets may be permitted to override the security – provided that the user permits it.

29 29 Thank you


Download ppt "Advanced Java Session 4 New York University School of Continuing and Professional Studies."

Similar presentations


Ads by Google