什么是 连接 connection ?

原文: http://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci555204,00.html

1) In telecommunication and computing in general, a connection is the successful completion of necessary arrangements so that two or more parties (for example, people or programs) can communicate at a long distance. In this usage, the term has a strong physical (hardware) connotation although logical (software) elements are usually involved as well.


A dialup (sometimes called a switched) connection is a telephonic arrangement that is set up only when needed, using shared, circuit-switched communication lines (as in "plain old telephone service"). A dedicated (sometimes called a non
-switched) connection is a continuous, always available connection (familiar to users of Digital Subscriber Line or DSL service). A leased line is a line rented from a telephone company that provides dedicated connection between two points (such as a headquarters office and a manufacturing plant).

 

2) In computer programming, a connection is the setting up of resources (such as computer memory and buffers) so that a particular object such as a database or file can be read or written to. Typically, a programmer encodes an OPEN or similar request to the operating system that ensures that system resources such as memory are set up, encodes READs and WRITES or similar requests, and then encodes a CLOSE when a connection is no longer needed so that the resources are returned to the system for other users.

A closely related term is session, which is sometime used to distinguish the ability to communicate for some duration in a logical sense. In this usage, the connection is regarded as the physical setup and the session is regarded as the logical setup. A session could be terminated and the connection maintained with the expectation of a new session later.

 

我觉得任何两台连接到Internet上的计算机其实都已经具有了physical connection,我们在代码中所做的一切都只是建立logical connection(其实就是session),这个logical connection建立的过程本质上是两个操作:

1 - 在本机内分配资源;

2 – 请求远端机器分配资源;

对于持续连接,通信双方分配的资源不会立刻释放,而非持续连接在每一次通信之前建立,通信结束后立刻释放。资源的分配比较低效,所以持续连接一般可以提升性能。

希望听听你们的意见。

原文地址:https://www.cnblogs.com/smwikipedia/p/1440655.html