


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Client: initiates contact with server (“speaks first”) typically requests service from server, for Web, client is implemented in browser; for e-mail, in mail reader Server: provides requested service to client e.g., Web server sends requested Web page, mail server delivers e-mail
applicationtransport networkdata link physical
applicationtransport networkdata link physical
request
reply
The socket is the basic abstraction for network communication in the socket API
Process B
Process A
Ports (Sockets)
Network
Protocol Family: PF_INET or PF_UNIX Communication semantics: SOCK_STREAM or SOCK_DGRAM
Usually UNSPEC
int bind (int socket, struct sockaddr *address, int addr_len)
This call is executed by:
It binds the socket to the specified address. The address parameter specifies the local component of the address, e.g. IP address and UDP/TCP port
Socket Descriptor Table 0: 1: 2: .. .
proto family: PF_INET
Socket Data Structure
service: SOCK_STREAM local address:
remote address:
address family: AF_INET
Address Data Structure
host IP: 128.173.88. port: 80
int listen (int socket, int backlog)
int accept (int socket, struct sockaddr *address, int *addr_len)
sockaddr is a generic address structure
sockaddr_in is specific instance for the Internet address family
struct sockaddr { u_short sa_family; // type of address char sa_data[14]; // value of address }
struct sockaddr_in { u_short sa_family; // type of address (AF_INET) u_short sa_port; // protocol port number struct in_addr sin_addr; // IP address char sin_zero[8]; // unused (set to zero) }