Socket communication in Java (i) socket introduction

Source: Internet
Author: User

A socket is also called a socket, and an application typically makes a request to the network through a socket or answers a network request.

In Java, the sockets and Servesocket class libraries are located in the java.net package. Seversocket is used for server-side, socket is used when establishing network connection. When the connection succeeds, a socket instance is generated at both ends of the application, manipulating the instance to complete the required session. For a network connection, sockets are equal, and there is no difference, not due to different levels on the server side or on the client. Either the socket or the ServerSocket their work is done through the socket class and its subclasses.


The process of establishing a socket link:

There are three steps to establishing a socket link:

1. Server Monitoring

2. Client making a request

3. Create and Confirm links

Once the client and server have confirmed the link, the socket continues to be listening and receives and transmits information to each other.

The socket has the following features:

1.Socket based on TCP link, data transmission is guaranteed

2.Socket is useful for establishing long-duration links that do not close randomly as HTTP requests do.

3.Socket programming is typically applied to instant messaging, an application that is inseparable from its first two-point feature.

Socket communication in Java (i) socket introduction

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.