Java Network Programming Libraries and Functions - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Java Network Programming Libraries and Functions

Description:

The java.net package makes socket programming relatively simple by providing a ... Network I/O uses Java's stream classes to read and write remotely, in the same ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 15
Provided by: paulsto8
Category:

less

Transcript and Presenter's Notes

Title: Java Network Programming Libraries and Functions


1
Java Network Programming Libraries and Functions
  • Paul Stockdale

2
Javas Network Class Libraries
  • The two main packages for dealing with network
    functions in Java are
  • java.net
  • java.rmi

3
The java.net Package
  • Two distinct categories of classes within
    java.net package
  • The Sockets API
  • Tools for working with URLs

4
Sockets API
  • Sockets are a low-level programming interface for
    networked communications, sending data streams
    between applications on the same or different
    hosts
  • The java.net package makes socket programming
    relatively simple by providing a simplified,
    object oriented interface
  • Network I/O uses Javas stream classes to read
    and write remotely, in the same way it would do
    locally

5
Three Types of Socket Class
  • java.net.Socket
  • java.net.DatagramSocket
  • java.net.MuliticastSockets

6
Protocols
  • Java only supports the Internet Protocol (IP)
  • The Socket class uses TCP (connection-oriented)
  • The DatagramSocket class uses UDP (connectionless)

7
Socket Class
  • Uses TCP, a connection-oriented protocol
  • Connection stays open even if no data is being
    sent
  • Data arrives in order it was sent
  • Data delivery is guarenteed

8
Clients and Servers
  • The Socket class is used by both client and
    server ends of a connection
  • Server also uses java.net.ServerSocket class to
    listen for new client connections
  • Server can use multiple Socket objects to
    simultaneously connect to multiple clients

9
DatagramSocket Class
  • Uses UDP, a connectionless protocol
  • End-to-end connections not set up in advance
  • Data is not kept in any order
  • No guarantee of data delivery

10
MulticastSocket Class
  • Variation of DatagramSocket Class
  • Sends to multiple recipients simultaneously
  • Not widely supported on the Internet

11
The java.rmi Package
  • Remote Method Invocation allows Java objects to
    communicate across a network
  • Applications can work with objects on remote
    hosts as if they were local
  • java.rmi provides a means for writing distributed
    applications using Java objects instead of data
    streams

12
Remote Method Invocation
  • Objects must be serialisable
  • Objects are passed by reference
  • Method invocations occur on the original object

13
RMI registry
  • Used to look up references to registered remote
    objects
  • Requires the rmiregistry application to be
    running on the local host
  • Unsophisticated and slow
  • Intended only to bootstap RMI communications
  • Other name services can be used

14
References
  • Niemeyer, P. and Knudsen, J. (June 2002) Learning
    Java 2nd Edition. Sebastopol, CA OReilly.
Write a Comment
User Comments (0)
About PowerShow.com