Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 14 Application Layer and Client-Server Model.

Similar presentations


Presentation on theme: "Chapter 14 Application Layer and Client-Server Model."— Presentation transcript:

1 Chapter 14 Application Layer and Client-Server Model

2 Figure 14-1

3 Client-Server Model

4 Figure 14-3

5 Concurrencia  Type of Running in Clientes  Iteratively: one-by-one  Concurrently: at the same time  Concurrency in Services:  Conectionless Iterative Server: from the same cliente of from different clients (i.e. UDP)  Conection-Oriented Concurrent Server: serves many clients at the same time.

6 Conectionless Iterative Server

7 Conection-Oriented Concurrent Server

8 Procesos  Concepto  Identificación  Creación

9 Identificación

10 Figure 14-10

11 Creación

12 Figure 14-12

13 Figure 14-13

14 Figure 14-14

15 Figure 14-15

16 Figure 14-16

17 Chapter 24 Socket Interface

18 Socket Types

19 Conectionless Iterative Server

20 Conection-Oriented Concurren Server

21 Figure 24-26 (repeated), Part I

22 Figure 24-26 (repeated), Part II

23 Figure 24-27, Part I

24 Figure 24-27, Part II

25 Sockets used for datagrams ServerAddress and ClientAddress are socket addresses Sending a messageReceiving a message bind(s, ClientAddress) sendto(s, "message", ServerAddress) bind(s, ServerAddress) amount = recvfrom(s, buffer, from) s = socket(AF_INET, SOCK_DGRAM, 0)

26 Sockets used for streams Requesting a connectionListening and accepting a connection bind(s, ServerAddress); listen(s,5); sNew = accept(s, ClientAddress); n = read(sNew, buffer, amount) s = socket(AF_INET, SOCK_STREAM,0) connect(s, ServerAddress) write(s, "message", length) s = socket(AF_INET, SOCK_STREAM,0) ServerAddress and ClientAddress are socket addresses

27 #include #define MAXBUF 256 #define PORT 2000 void main(void) { char buf[MAXBUF]; int activeSocket; int remoteAddrLen; struct sockaddr_in remoteAddr; struct sockaddr_in localAddr; struct hostent *hptr;

28 activeSocket = socket(AF_INET, SOCK_DGRAM, 0); memset(&remoteAddr, 0,sizeof(remoteAddr)); remoteAddr.sin_family =AF_INET; remoteAddr.sin_port=htons(PORT); hptr=gethostbyname("a-domain-name"); memcpy((char*)&remoteAddr.sin_addr.s_addr,hptr->h_addr_list[0],hptr- >h_length); connect(activeSocket, &remoteAddr, sizeof(remoteAddr)); memset(buf, 0, MAXBUF); remoteAddrLen = sizeof(remoteAddr); while { sendto(activeSocket, buf, sizeof(buf), 0, &remoteAddr,sizeof(remoteAddr$ memset(buf, 0, sizof(buf)); recvfrom(activeSocket, buf, MAXBUF, 0, &remoteAddr,&remoteAddrLen); printf("%s\n", buf); memset(buf, 0, sizeof(buf)); }; close(activeSocket); }

29 Anexo

30 Socket System Calls

31 Figure 24-18

32 Figure 24-21

33 Data types

34 Internal Sockets Address Structure

35 Sockets Structure

36 Byte Ordering

37 Figure 24-8

38

39 Order Translation

40 Byte Manipulation functions

41 Information About Remote Host

42 Figure 24-14


Download ppt "Chapter 14 Application Layer and Client-Server Model."

Similar presentations


Ads by Google