Cirrus Logic CS485 Manual de usuario Pagina 49

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 67
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 48
CS485G Spring 2015 49
9. Sample client for ”echo”
1 int client(int argc, char
**
argv) {
2 int toserverfd, port;
3 char
*
host, buf[MAXLINE];
4 rio_t rio;
5 if (argc != 3) {
6 fprintf(stderr, "Usage: %s host port\n", argv[0]);
7 exit(1);
8 }
9 host = argv[1]; port = atoi(argv[2]);
10 toserverfd = open_clientfd(host, port);
11 Rio_readinitb(&rio, toserverfd);
12 printf("type: "); fflush(stdout);
13 while (Fgets(buf, MAXLINE, stdin) != NULL) {
14 Rio_writen(toserverfd, buf, strlen(buf));
15 Rio_readlineb(&rio, buf, MAXLINE);
16 printf("echo: ");
17 Fputs(buf, stdout);
18 printf("type: "); fflush(stdout);
19 }
20 Close(toserverfd);
21 exit(0);
22 } // client
Vista de pagina 48
1 2 ... 44 45 46 47 48 49 50 51 52 53 54 ... 66 67

Comentarios a estos manuales

Sin comentarios