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