1 / 9

Chapter 5 Socket API

Chapter 5 Socket API. 1980, a group at UC Berkeley create a interface that applications use to communicate. Known as socket API or socket interface System is known as Berkeley UNIX or BSD UNIC. Specifying a protocol interface. Two broad approaches

Download Presentation

Chapter 5 Socket API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5 Socket API • 1980, a group at UC Berkeley create a interface that applications use to communicate. • Known as socket API or socket interface • System is known as Berkeley UNIX or BSD UNIC

  2. Specifying a protocol interface • Two broad approaches • Define functions specifically to support TCP/IP communication • Define functions that support network communication in general, and use parameters to make TCP/IP communication a special case. • Because the designer at Berkeley wanted to accommodate multiple sets of communication protocol, they used the second approach.

  3. In fact, they provides for generality far beyond TCP/IP. They allowed for multiple families of protocols, with all TCP/IP protocols represented as single family(family PF_INET) • The socket API provides generalized functions that support network communication using many possible protocols as a single protocol family. The calls allow the programmer to specify the type of service required rather than the name of specific protocol.

  4. Socket abstraction • File descriptors • Open function create a file descriptor • The OS maintains a separate file descriptor as an array of pointers to internal data structure • Application program only need to remember the descriptor and use it

  5. Socket API adds a new abstraction for network communication, the socket. • Each active socket is identified by a small integer called its socket descriptor • OS provides a separate system function, socket, that applications call to create a socket; • Application only use open to crate file descriptor • Once the socket has been created, an application must make additional system calls to specify the details of its exact use.

  6. System data structure for sockets Operating system Descriptor table ( one per process) Family: PF_INET 0: Service:SOCK_STREAM 1: Local IP: 2: Remote IP: 3: Local Port: 4: Remote Port:

  7. Using sockets • A socket used by a server to wait for an incoming connection is called a passive socket • A socket used by a client to initiate a connection is called an active socket. • The sockets are created the same way initially

  8. Endpoint address • When a socket is created, it does not contain detailed information about how it will be used. (port number, IP address) • ICP/IP protocols define a communication endpoint to consist of an IP address and a protocol port number. • It allows each protocol family to specify endpoints however it likes • TCP/IP protocols all use a single address representation, with address family AF_INET

  9. Generic address structure • Struct sockaddr{ • u_char sa_len; // total length • U_short sa_family; // type of address • char sa_data[14]; // value of address • }

More Related