1 / 42

Chapter 14

Chapter 14. Application Layer and Client-Server Model. Figure 14-1. Client-Server Model. Figure 14-3. Concurrencia. Type of Running in Clientes Iteratively: one-by-one Concurrently: at the same time Concurrency in Services:

gabe
Download Presentation

Chapter 14

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 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 SocketInterface

  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. Sending a message Receiving a message s = socket(AF_INET, SOCK_DGRAM, 0) s = socket(AF_INET, SOCK_DGRAM, 0) bind(s, ClientAddress) bind(s, ServerAddress) sendto(s, "message", ServerAddress) amount = recvfrom(s, buffer, from) ServerAddress and ClientAddress are socket addresses Sockets used for datagrams

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

  27. #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <stdio.h> #include <string.h> #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. Order Translation

  39. Byte Manipulation functions

  40. Information About Remote Host

  41. Figure 24-14

More Related