1. Fill in blank questions (1) There are two classes in the java.net package
SocketAnd
ServersocketUsed to create socket communication on the client and server respectively. (2) We can use the socket method separately.
Dateinputstream ()And
Dateoutputstream ()To create an input/output stream. (3) You can use
Accept ()Method to receive connection requests from the client program. After the communication task is completed
Close ()Method to disable the communication socket. (4) we can use
DatagramsocketClass to establish a socket for datagram communication; Use
DatagrampacketClass to create a data packet package. (5) We can
DatagrampacketClass Method
Datagrampacket (byte [] Buf, int length, inetaddress address, int port)Obtains the byte array encoding of packets from the instance.
Getaddress () To return the IP address of the machine that sends or receives the packet. (6) we can call
Receive ()Method to receive data packets.
Send ()Method To send a datagram. (7) after the communication task is completed
Close ()Method to disable the datagram communication socket. (8) create a URL object
4Method
{Public URL (string spec) Public URL (URL context, string spec) Public URL (string protocol, string host, string file) Public URL (string protocol, string host, int port, string file )}(9) In the new URL (URL, string) format, the string parameter indicates
URLFile Path(10) string URL. gethost () indicates that
Obtain the Host Name of the URL.(11) string URL. GetFile () indicates obtaining
Get the URL File Name