Android Network programming package: 9 packets, 20 interfaces, 103 categories, 6 enumeration, 14 exceptions;
--Java package: Java.net package (6 interfaces, 34 categories, 2 enumeration, 12 exceptions );
--Android package: Android.net package (1 interface, 19 classes, 3 enumeration, 1 exception), android.net. http packet (6 types), android.net. nsd package (3 interfaces, 2 categories), android.net. rtp (class 4), android.net. sip package (1 interface, 9 categories, 1 exception), android.net. wifi package (16 categories, 1 enumeration), android.net. wifi. p2p package (9 interfaces, 7 categories), android.net. wifi. p2p. nsd package (6 categories );
ContentHandlerFactory: This interface defines the content processing program factory;
DatagramSocketImplFactory: This interface defines the factory for implementing user datagram;
FileNameMap: DefinedIng between file names and MIME Type stringsInterface;
SocketImplFactory: Define the socket implementation factory;
SocketOptions: DefinitionObtain the method for setting SOCKET optionsInterface;
URLStreamHandlerFactory: Defines the URL stream protocol handler factory;
1. ContentHandlerFactory
Function: Defines the content processing program factory. The implementation class of this interface is responsible for ing the MIME type to the ContentHandler instance object;
MIME parsing:
--Extension: Multipurpose Internet Mail Extentions multi-purpose Internet Mail Extension type;
--Function: Use Program B to open A file with the extension A. When the file with the extension A is accessed, the browser will automatically call program B to open the file with the extension;
--Usage: Mostly used to associate custom file suffix file opening methods and media file opening methods;
Interface Environment: URLStreamHandler uses the method implemented by this interface to create the ContentHandler of the MIME Type;
Interface Method Parsing:
ContentHandler createContentHandler(String mimetype)
--
Function: Create a New ContentHandler. The ContentHandler can read objects from URLStreamHandler;
2. DatagramSocketImplFactory
Function: Defines the factory used for data PACKET socket implementation;
Interface Environment: Assumramsocket uses this interface to create a socket instance;
Interface Method Parsing:
DatagramSocketImpl createDatagramSocketImpl()
--
Function: Create an DatagramSocketImpl instance object;
3. FileNameMap
Function:File NameAndMIME Type stringInterfaces required for ing between them;
Interface Method Parsing:
String getContentTypeFor(String fileName)
--
Function: Gets the MIME Type string of the specified file name;
4. SocketImplFactory
Function: Defines the socket implementation factory;
Environment: Socket and ServerSocket use the method defined by this interface to create a Socket instance;
Method Analysis:
SocketImpl createSocketImpl()
--
Function: Create a new socket instance;
5. SocketOptions
Function: DefinedSet to getMethod of socket options;
Interface Environment: SocketImpl and DatagramSocketImpl implement this interface. subclasses of these two classes should rewrite this interface to support the options of subclass of the two classes;
(1) constant field Parsing
IP_MULTICAST_IF: Sets an outgoing interface (eth0, eth1, wlan0, etc.) for sending multicast packets );
--Environment:Multiple Network InterfacesIn general, in this case, the application does not use the default system interface, but uses other interfaces;
IP Multicast: One host (Multicast Source) simultaneously sends the same data to multiple hosts;
IP-MULTICAST_IF2: Works the same as IP_MULTICAST_IF, but supports IPv4 IPv6.Version 1.4Start to support;
IF_MULTICAST_LOOP: Used to start or disable multicast datagram sending. The default status is start;
IP_TOS: InIP Address HeaderSet tcp udp datagramService TypeOrTraffic Field;
TOS (Type Of Service): The packet forwarding priority in the network area. The following is a common constant service type in a single byte;
--IPTOS_LOWDELAY: Minimize latency;
--IPTOS_THROUGHPUT: Optimized throughput;
--IPTOS_RELIABILITY: Reliability optimization;
--IPTOS_MINCOST: Fill in the data, which can be transmitted at low speed, irrelevant;
SO_BINDADDR: Obtain the local address of the bound socket;
--The local socket address cannot be changed.: The socket is bound to a local address when it is created, so it cannot be changed;
--Default socket address: INADDR_ANY indicates any address of a multi-host (host with multiple IP addresses;
SO_REUSEADDR: Used only for MulticastSocket. This option is set by default for MulticastSocket, which is valid for DatagramSocketImpl;
SO_BROADCAST: Enable the processing capability to disable sending of broadcast messages;
--Use Cases: Datagram socket, supporting the network of the concept of broadcast message;
--Default settings: DatagramSocket starts this option by default;
SO_KEEPALIVE: This option is set for TCP Socket. If data is not transmitted through Socket within 2 hours, TCP will send the keepalive probe to the same body;
--Function: Checks whether the same-bit host crashes;
--Applicability: Valid only for TCP sockets;
--The same body uses the expected ACK response: The application is not notified. After no data is transmitted for the other two hours, TCP continues to send a probe;
--Same-bit response through RST: Notifies the local TCP same-bit host to crash and closes socket to restart the host;
--No response from the same-Bit Body: Directly close the socket;
SO_LINGER: The timeout value for closing the stay, that is, the waiting time after the TCP Socket closes;
--Enable non-0 timeout value: After close (), it is blocked until transmission and read/write confirmation are completed. If it times out, it will be forcibly closed through tcp rst;
--Enable 0 timeout value: After close (), it will be forced to close without any waiting;
SO_OOBINLINE: Whether to discard tcp emergency data received by the socket;
--Startup options: Tcp emergency data received by the socket is received through the socket input stream;
--Disable Option: The received tcp emergency data is directly discarded;
SO_RCVBUF (receive): Set NetworkInputThe buffer size;
--Set Method usage: Set through socketReceive dataThe size of the buffer used;
--Obtain method usage: Get socket settingsReceive dataBuffer size;
--Applicability: SocketImpl, DatagramSocketImpl;
SO_SNDBUF (send): Set NetworkOutputThe basic I/O buffer size prompt used;
--Set Method usage: Set through socketSend dataThe size of the buffer used;
--Obtain method usage: Get socket settingsSend dataBuffer size;
--Applicability: SocketImpl, DatagramSocketImpl;
SO_TIMEOUT: Set the timeout value for Socket blocking;
--Timeout operation: ServerSocket. accept (), SocketInputStream. read (), DatagramSocket. receive ();
--Set Time: This option is valid only when it is set before it is blocked. If it is blocked, the setting will not take effect for this blocking;
--Timeout Processing: If a timeout occurs, the blocking operation will continue, but InterruptedIOException will be thrown, and the Socket will not be closed;
--Applicability: This setting is valid for all Sockets (SocketImpl, DatagramSocketImpl;
TCP_NODELAY: Set the link of this parameter to disable the nagle algorithm;
Nagle algorithm analysis: Reduce the number of packages, which is used to increase the efficiency of network software and avoid the use of 40 bytes of header files for a packet containing only one byte;
(2) interface methods
void setOption(int optID, Object value) throws SocketException
--
Function: Enable/disable the specified option. If enabled, the value option is used;
--Option input error: If the format of the input value is incorrect, an error occurs;
--Input Basic Data Type: Uses Integer Boolean and Other encapsulation;
--Disable Option: New Boolean (false) can be used to disable any option. This option is enabled if other content is input;
--Exception: If the options match incorrectly or the socket is closed, a SocketException exception is reported;
Object getOption(int optID) throws SocketException
--
Function: Get the option value;
6. URLStreamHandlerFactory
Interface Function: Defines the factory of the URL stream protocol processing program. The URL class implements this interface to create URLStreamHandler for a specific protocol;
createURLStreamHandler URLStreamHandler createURLStreamHandler(String protocol)
--
Function: Create a New URLStreamHandler instance with the specified protocol;
,