Java socket long connection with short link

Source: Internet
Author: User



A long connection is once a client logs on to the server and its connection to the server does not close, regardless of how many transactions are made between them, until the client exits the login or the network fails.

This technology is implemented in online trading systems to improve efficiency.
A short connection is a client each request to establish a connection with the server, the transaction is completed after closing the connection, this technology to achieve a longer connection simple.

Long: Connect after the continuous open, for multiple send and receive operations.
Short: Connect every time, complete the task immediately after the disconnection, the next re-connect.

Generally, after the accept starts a thread to process, the processing of this thread is roughly as follows

Short connections:
Run () {
Read//Reading request package
Process//Processing
Write//Answer processing results
}

Long connections:
Run () {
while (Notend) {
Read
Process
Write
}
}

Java socket long connection with short link

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.