Java Network programming

Source: Internet
Author: User

InetAddress

  InetAddress is used to represent an IP address, and a inetaddress represents an IP address

How to create an InetAddress object, Getbyname (String host), can be an IP, or it can be a domain name

GetHostName (): Gets the domain name corresponding to the IP address

Gethostaddress (): Get IP Address

InetAddress byname = Inetaddress.getbyname ("www.baidu.com"); // Establish an IP address        String hostName = Byname.gethostname (); // get the domain name        of the IP address String address = byname.gethostaddress (); // Get IP Address         System.out.println (hostName);        SYSTEM.OUT.PRINTLN (address);

Socket

  Using sockets to develop Web applications has long been widely adopted as a de facto standard.

A socket on both ends of the communication is the endpoint of the communication between the two computers.

Network communication is actually the communication between sockets

The socket allows the program to treat the network connection as a stream, and the data is transmitted via IO between two sockets.

Java Network programming

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.