API functionality API must support Allocate local resources for communication Specify local and remote communication endpoints Initiate a connection( client side) Wait for a connection (server side) Send or receive data Determine when data arrives Generate urgent data Terminate a connection gracefully Handle connection termination from the remote site abort communication Handle error condition or a connection abort Release local resources when communication finishes 哈工大计算机学院李全龙 Network Application Development Socket Programming 6
哈工大计算机学院 李全龙 Network Application Development Socket Programming 6 API functionality API must support: Allocate local resources for communication Specify local and remote communication endpoints Initiate a connection (client side) Wait for a connection (server side) Send or receive data Determine when data arrives Generate urgent data Terminate a connection gracefully Handle connection termination from the remote site Abort communication Handle error condition or a connection abort Release local resources when communication finishes
Conceptual interface specification The TCP/IP standards do not leave implementors without any guidance They specify a conceptual interface: a set of procedures and functions The conceptual interface defined by tcp/Ip standards does not specify data representations or programming details It merely provides an example of one possible interface that an OS can offer to application programs that use TCP/IP 哈工大计算机学院李全龙 Network Application Development Socket Programming 7
哈工大计算机学院 李全龙 Network Application Development Socket Programming 7 Conceptual interface specification The TCP/IP standards do not leave implementors without any guidance. They specify a conceptual interface: a set of procedures and functions. The conceptual interface defined by TCP/IP standards does not specify data representations or programming details; It merely provides an example of one possible interface that an OS can offer to application programs that use TCP/IP
Implementation of an API All implementations of a particular API appear the same to programmers: the API merely consists of a set of procedures( or functions)that an application program can call to establish communication or send and receive data In practice, the implementation of the api depends on the under lying system Sharing API code might reside in the computer's OS or it might reside in a region of memory devoted to shared libraries Win95/ 98 uses a shared lib scheme known as Dynamic Linked Library (DLL) 哈工大计算机学院李全龙 Network Application Development Socket Programming 8
哈工大计算机学院 李全龙 Network Application Development Socket Programming 8 Implementation of an API All implementations of a particular API appear the same to programmers: the API merely consists of a set of procedures ( or functions) that an application program can call to establish communication or send and receive data. In practice, the implementation of the API depends on the underlying system. Sharing API code might reside in the computer’s OS, or it might reside in a region of memory devoted to shared libraries. Win95/98 uses a shared lib scheme known as Dynamic Linked Library (DLL)
Implementation of an API Win95/98 p)(4p ppn App programs DLL containing socket interface procedures Socket API DLL containing TCP /IP software -TCP/IP functions Operating system Functions I/O functions 哈工大计算机学院李全龙 Network Application Development Socket Programming 9
哈工大计算机学院 李全龙 Network Application Development Socket Programming 9 Implementation of an API Win95/98 : Operating System Functions DLL containing TCP/IP software DLL containing socket interface procedures App1 App2 Appn TCP/IP functions …… App programs Socket API I/O functions
Implementation of an API Windows nt/2000/XP uses a hybrid scheme that includes both a dll and resident code App2 App pp programs DLL containing socket interface procedures Socket api TCP/IP functions Operating System Functions and io functions 哈工大计算机学院李全龙 Network Application Development Socket Programming 10
哈工大计算机学院 李全龙 Network Application Development Socket Programming 10 Implementation of an API Windows NT/2000/XP uses a hybrid scheme that includes both a DLL and resident code. Operating System Functions DLL containing socket interface procedures App1 App2 …… Appn App programs Socket API TCP/IP functions and I/O functions