【正文】
riptors, And work I/O Socket munication also uses the descriptor approach. Before an application can use protocols to municate,the application must request the operating system to create a socket that will be used for munication. The system returns a small integer descriptor that identifies the socket. In a Unix implementation,sockets are pletely integrated with other I/o. A single application can be written that transfers data to an arbitrary location. 網(wǎng)絡(luò)中可以被命名和尋址的通信端口,是操作系統(tǒng)可分配的一種資源。 其次,操作系統(tǒng)支持的網(wǎng)絡(luò)協(xié)議眾多, 不同協(xié)議的工作方式不同,地址格式也不同。同一主機(jī)上,不同進(jìn)程可用進(jìn)程號(hào)( process ID)唯一標(biāo)識(shí)。 可以把同機(jī)進(jìn)程通信看作是其中的特例。 由于每個(gè)進(jìn)程都在自己的地址范圍內(nèi)運(yùn)行,為保證兩個(gè)相互通信的進(jìn)程之間既互不干擾又協(xié)調(diào)一致工作,操作系統(tǒng)為進(jìn)程通信提供了相應(yīng)設(shè)施: 如 UNIX BSD中的管道( pipe)、命名管道( named pipe)和軟中斷信號(hào)( signal),UNIX system V的消息( message)、共享存儲(chǔ)區(qū)( shared memory)和信號(hào)量( semaphore)等,但都僅限于用在本機(jī)進(jìn)程之間通信。 首先,進(jìn)行網(wǎng)絡(luò)操作的兩個(gè)進(jìn)程可能在不同主機(jī)上,如何建立它們之間的聯(lián)系? 其次,存在多種網(wǎng)絡(luò)協(xié)議,如何建立一種通用機(jī)制以支持多種協(xié)議? 這些都是網(wǎng)絡(luò)應(yīng)用編程所要解決的問(wèn)題。 TCP/IP協(xié)議被集成到 UNIX內(nèi)核中時(shí),相當(dāng)于在 UNIX系統(tǒng)引入了一種新型的 I/O操作。 然后這個(gè)用戶(hù)進(jìn)程多次調(diào)用“讀 /寫(xiě)”以傳輸數(shù)據(jù)。 UNIX系統(tǒng)的 I/O命令集,其模式為打開(kāi)一讀 /寫(xiě)一關(guān)閉( openwritereadclose)。 TCP/IP 協(xié)議族也與 Unix 的發(fā)展有很密切關(guān)系。T Unix 演化而來(lái)。T 公司 Bell實(shí)驗(yàn)室于 1969年開(kāi)發(fā)。Computer Networks and Inters 《 計(jì)算機(jī)網(wǎng)絡(luò)與因特網(wǎng) 》 課件 PART IV Network Applications Chapter 27 The Socket Interface Socket 接口 Introduction The interface between an application and protocol software. How an application uses protocol software to munication. Set of procedures that an application uses to bee a client or a server, to contact a remote destination, or to transfer data. Application Program Interface Client and server application use transport protocols to municate. The interface an application uses when it interacts with transport protocol software is known as an Application Program Interface (API). An API defines a set of operations that an application can perform when interacting with protocol software, the API determines the functionality that is available. The Socket API Although protocol standards allow operating system designers to choose an API, many have adopted the Socket API. The Socket API is available for many operating systems. The Socket API originated as part of the BSD Unix operating system. The Socket API is a de facto standard. Sockets And Socket Libraries In BSD Unix and the system derived from it,socket functions are part of the operating system itself. In many cases,instead of modifying their basic operating system,vendor