Jdk_api Anatomy of the java.net pack

Source: Internet
Author: User
Tags http cookie idn rfc

Provides classes for implementing network applications. (in alphabetical order)

1, Authenticator
    • Abstract class
    • Starting from 1.2 There are
    • No parent classes and interfaces
    • The Authenticator class represents an object that knows how to obtain network connection validation. Typically, it does this by prompting the user to enter information. The application getPasswordAuthentication() uses this class by overriding subclasses. This method typically uses various GetXXX () accessor methods to obtain information about the entity that requested validation. It must then obtain the user name and password by interacting with the user or some other non-interactive means. The credentials are then PasswordAuthentication returned as return values. Next, the setDefault(Authenticator) instance of this specific subclass is registered to the system by calling. When validation is required, the system calls one of the requestpasswordauthentication () methods, which in turn invoke the Getpasswordauthentication () method of the registered object. All methods that request validation have a default implementation that fails

2. bindexception
    • Class, exception
    • Starting from 1.1 There are
    • Inherit SocketException
    • This exception is thrown when an error occurs when attempting to bind a socket to a local address and port. These errors typically occur when the port is in use or the requested local address cannot be allocated.

3, CacheRequest
    • Abstract class
    • Starting from 1.5 There are
    • No parent classes and interfaces
    • Represents a channel that stores resources in Responsecache. Instances of this kind provide an OutputStream object that the protocol handler can call to store the resource data in the cache, and an abort () method that allows for interrupt and discard cache storage operations. If you encounter IOException while reading a response from the cache or writing a response to the cache, the current cache store operation is aborted.

4. Cacheresponse
    • Abstract class
    • Starting from 1.5 There are
    • No parent classes and interfaces
    • Represents a channel that obtains resources from Responsecache. Instances of this kind provide inputstream that return the entity body and provide a getheaders () method that returns the associated response header.

5. connectexception
    • Class, exception
    • Starting from 1.1 There are
    • Inherit SocketException
    • This exception is thrown when an error occurs attempting to connect a socket to a remote address and port. These errors typically occur when a remote connection is denied (for example, no process is listening on a remote address/port).

6. ContentHandler
    • Abstract class
    • Starting from 1.0 there are
    • No parent
    • An abstract class ContentHandler is URLConnection a Object superclass of all classes that are read from. Applications typically do not call methods directly in this class getContent . Instead, URL URLConnection the method in the call or class getContent . The application's content handler factory (an instance of the class that implements ContentHandlerFactory the interface, which is invoked by the invocation setContentHandler setting) is invoked by a String String that gives the MIME type of the object that will be received on the socket. The factory returns ContentHandler an instance of the subclass and calls its getContent method to create the object.

7, ContentHandlerFactory
    • Interface
    • Starting from 1.0 there are
    • No parent
    • This interface defines the factory for the content handler. The implementation of this interface should map the MIME type to ContentHandler the instance. URLStreamHandlerclass uses this interface to create MIME types ContentHandler .

    • Creates a URLStreamHandler new method for reading from an object ContentHandler Createcontenthandler (String mimetype)
8, Cookiehandler
    • Abstract class
    • Starting from 1.5 There are
    • No parent
    • The Cookiehandler object provides a callback mechanism to hook an HTTP status management policy implementation to an HTTP protocol handler. The HTTP State management mechanism uses HTTP requests and responses to specify how stateful sessions are created.

      You can register the system-level cookiehandler to be used by the HTTP protocol handler by executing Cookiehandler.setdefault (Cookiehandler). Call Cookiehandler.getdefault () to get the currently registered Cookiehandler. For more information about HTTP state management, see RFC 2965:http State management mechanisms .

9, Cookiemanager
    • Abstract class
    • Starting from 1.6 There are
    • Inherit Cookiehandler
    • Cookiemanager provides CookieHandler a specific implementation that separates the store of cookies from the policy surrounding the acceptance and rejection of cookies. Initializes the Cookiemanager using an object that manages the store CookieStore and makes a cookie accept/reject decision CookiePolicy .

      The HTTP cookie Management in the java.net package is as follows:

      Usecookiehandler <-------httpurlconnection       ^| impl|         Usecookiemanager-------> cookiepolicy|   use|--------> HttpCookie             |              ^|              | use|   Use        | | --------> Cookiestore                            ^| impl                            
10, Cookiepolicy
    • Interface
    • Starting from 1.6 There are
    • No parent
    • Cookiepolicy implementation determines which cookie should be accepted and which cookie should be rejected. Three predefined policy implementations are available, namely Accept_all, Accept_none, and Accept_original_server.

11. Cookiestore
    • Interface
    • Starting from 1.6 There are
    • No parent
    • A Cookiestore object that represents the cookie store. Cookies can be stored and obtained. CookieManagercall Cookiestore.add to save the cookie for each incoming HTTP response, and call Cookiestore.get to get the cookie for each outgoing HTTP request. Cookiestore is responsible for removing expired HttpCookie instances.

12, Datagrampacket
    • Final class
    • Starting from 1.0 there are
    • No parent
    • This class represents a datagram package. Packet delivery service for non-connected packets. Each message is routed from one machine to another based only on the information contained in the package. Multiple packages sent from one machine to another may choose different routes, or they may arrive in a different order. No warranties are made for package delivery.

13. Datagramsocket
    • Class
    • Starting from 1.0 there are
    • No parent
    • This class represents the socket used to send and receive datagram packets.

      A datagram socket is a send or receive point for a package delivery service. Each packet sent or received on a datagram socket is individually addressable and routed. Multiple packages sent from one machine to another may choose different routes, or they may arrive in a different order.

      UDP broadcast forwarding is always enabled on Datagramsocket. In order to receive a broadcast packet, the Datagramsocket should be bound to a wildcard address. In some implementations, a broadcast packet can also be received when a datagramsocket is bound to a more specific address.

      Example: DatagramSocket s = new DatagramSocket(null); s.bind(new InetSocketAddress(8888)); this is equivalent to: DatagramSocket s = new DatagramSocket(8888); Two examples can create a datagramsocket that can receive broadcasts on UDP 8888 ports.

14, Datagramsocketimpl
    • Abstract class
    • Starting from 1.1 There are
    • Implement Socketoptions
    • Abstract base class for datagram and multicast sockets implementations.
15, Datagramsocketimplfactory
    • Interface
    • Starting from 1.3 There are
    • No parent
    • This interface defines the factory used for datagram socket implementations. DatagramSocketclass uses it to create an actual socket implementation.

    • Method DatagramsocketimplcreateDatagramSocketImpl()
16, fileNameMap
    • Interface
    • Starting from 1.3 There are
    • No parent
    • A simple interface that provides a mechanism for mapping between file names and MIME type strings.

    • MethodString getContentTypeFor(String fileName),获取指定文件名的 MIME 类型。
17, HttpCookie
    • Final class
    • Starting from 1.6 There are
    • Implement Cloneable
    • The HttpCookie object represents an HTTP cookie with state information between the server and the user agent. Cookies are widely used to create stateful (stateful) sessions.

18, HttpURLConnection
    • Abstract class
    • Starting from 1.1 There are
    • Inherit URLConnection
    • URLConnection that support HTTP-specific features. For more information, see the spec. Each httpurlconnection instance can be used to generate a single request, but other instances can transparently share the underlying network connected to the HTTP server. The call to the close () method on HttpURLConnection's InputStream or outputstream after the request frees the network resources associated with this instance, but has no effect on the shared persistent connection. If the persistent connection is idle when calling disconnect (), the underlying socket may be closed.

19. IDN
    • Final class
    • Starting from 1.6 There are
    • No parent
    • Provides methods for internationalizing domain name (IDN) conversions between ordinary Unicode representations and ASCII compatibility Encoding (ACE) representations. Internationalized Domain names can use characters in the entire Unicode range, whereas traditional domain names are limited to ASCII characters. Aces are Unicode string encodings that use only ASCII characters and can be used with software that recognizes only traditional domain names, such as the domain name System.

20, Inet4address
  • Final class
  • Starting from 1.4 There are
  • Inherit InetAddress
  • This class represents the Internet Protocol version 4 (IPV4) address. This class is made up of RFC 790:assigned Numbers,RFC 1918:address Allocation for Private internets , and RFC 2365:administ ratively Scoped IP multicast defined.

    Text representation of an IP address

    The textual representation of the IPV4 address used as a method input takes one of the following forms:

    D.d.d.d
    D.d.d
    D.d
    D

    When you specify four parts, each part is interpreted as a data byte and assigned from left to right to the four bytes of the IPV4 address.

    When you specify a three-part address, the last part is interpreted as a 16-bit amount and placed at the rightmost two bytes of the network address. This makes the three-part address format convenient for specifying the Class B network address as 128.net.host.

    When a two-part address is provided, the last part is interpreted as a 24-bit amount and placed at the rightmost three bytes of the network address. This makes the two-part address format easier to designate the Class A network address as Net.host.

    When only one part is given, the value is stored directly in the network address, eliminating the need for byte rearrangement.

    For methods that return text representations as output values, the first form is used, even if the four strings are separated by a dot.

21, Inet6address
    • Final class
    • Starting from 1.4 There are
    • Inherit InetAddress
    • This class represents an Internet Protocol version 6th (IPV6) address.

22, InetAddress
    • Class
    • Starting from 1.0 there are
    • Implement Serializable
    • This class represents an Internet Protocol (IP) address.

23, Inetsocketaddress
    • Class
    • Starting from 1.0 there are
    • Inherit socketaddress
    • This class represents an Internet Protocol (IP) address.

Jdk_api Anatomy of the java.net pack

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.