The Network Access Layer

   

Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 20.  Network Programming


Network Access occupies the bottom layer of the diagram. The software in this layer talks to the hardware indirectly using the drivers that are provided (normally) by the network card manufacturer.

The basic unit of transfer at this level is the frame. Frames contain the information needed to move the data from one physical network card to another. This layer uses the physical address that identifies the card to transfer the data. This layer also knows how to handle the physical characteristics of the hardware, including the maximum frame size and the hardware-addressing scheme.

Figure 20.3 shows this encapsulation and decapsulation strategy diagrammatically.

Figure 20.3. TCP/IP Data encapsulation and decapsulation.

graphics/20fig03.gif

Each layer adds its own header and trailer. Its peer layer on the other stack peels off the header and trailer that were added by that layer on the sending side. It then hands the slimmed-down message to the previous layer.

TCP/IP applications can be programmed in any language that can open a socket. Many languages require that you use an operating system utility to do this. For portability reasons, Java doesn't allow operating system calls from within programs. Instead, network functionality is provided by the classes in the java.net package. The Java Virtual Machine is responsible for providing the actual connection to the operating system.

The java.net package includes the following important classes:

  • Socket class Sends TCP messages

  • ServerSocket class Creates servers

  • URL class An object representing a Uniform Resource Locator

  • URLConnection The superclass of all classes that represent a communications link between the application and a URL


       
    Top
     



    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net