[Zz] long connection and short connection

Source: Internet
Author: User
Tags socket error

What is persistent connection?

In fact, persistent connections are relative to common short connections, that is, to maintain the connection between the client and the server for a long time.

The common short connection procedure is as follows:

Connection-data transmission-close connection;

The persistent connection is usually:

Connection-data transmission-keep connection... -Close connection;

This requires that long connections send data packets regularly when there is no data communication to maintain the connection status. Short connections can be closed directly when there is no data transmission.

When can I use persistent connections or short connections?

Persistent connections are mainly used inMinorityClient and serverFrequentCommunication, because in this case, if a short connection is used for frequent communication, a socket error will often occur, and frequent creation of socket connections is also a waste of resources.

However, for the server, persistent connections consume certain resources and require dedicated threads (process management can be used in UNIX) to maintain the connection status.

In short, the choice of persistent connection and short connection depends on the situation.

 

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.