Tag: Test row represents network traffic for throw get static str
Brief introduction:
PORT: 1
1. Used to differentiate different applications.
2. Port number range 0~65535, 0~1023 is reserved for the system.
The 3.IP address and port number make up the socket. Sockets are the endpoints of two-way communication links between programs running on the network, and are the basis for TCP and UDP.
4. Common port number HTTP ftp:21 telnet 23
Network support in Java:
For the different levels of network communication, divided into four categories
1.InetAddress, which represents the hardware class on the network (identifies IP address related information)
2.URL: Network Resource location
3.Sockets: For TCP
4.Datagram: For UDP
Package com. inetaddress;
Import java.net.InetAddress;
Import java.net.UnknownHostException;
Import Java.util.Arrays;
public class Test1 {
public static void Main (string[] args) throws unknownhostexception{
InetAddress address = Inetaddress.getlocalhost ();
SYSTEM.OUT.PRINTLN ("Computer name:" + address.gethostname ());
SYSTEM.OUT.PRINTLN ("Address of the computer:" + address.gethostaddress ());
byte[] bytes = address.getaddress ();//Get IP in byte array form
System.out.println (arrays.tostring (bytes));
SYSTEM.OUT.PRINTLN (address);
InetAddress address2 = inetaddress.getbyaddress (bytes);
InetAddress address2 = Inetaddress.getbyname ("");
System.out.println (Address2.gethostaddress ());
}
}
Java Socket Programming