循環服務器,并發服務器模型以及I/O多路轉接模型

https://blog.csdn.net/xinianbuxiu/article/details/53455784

一、基于TCP/IP協議的基本循環服務器

tcp_server.c

?

 
  1. #include <stdio.h>

  2. #include <stdlib.h>

  3. #include <string.h>

  4. ?
  5. #include <sys/types.h>

  6. #include <sys/socket.h>

  7. #include <sys/stat.h>

  8. #include <netdb.h>

  9. ?
  10. #define PORT 3333

  11. #define MAX_SIZE 1024

  12. ?
  13. int main()

  14. {

  15. int sockfd;

  16. int new_fd;

  17. ?
  18. struct sockaddr_in server_addr;

  19. struct sockaddr_in client_addr;

  20. ?
  21. int n_read;

  22. int ser_size;

  23. int opt = 1;

  24. ?
  25. char buffer[MAX_SIZE];

  26. ?
  27. if((sockfd = socket(AF_INET,SOCK_STREAM,0)) < 0)

  28. {

  29. perror("socket error!\n");

  30. exit(1);

  31. }

  32. ?
  33. printf("socket success.............!\n");

  34. ?
  35. if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)) < 0)

  36. {

  37. perror("set socket option error!\n");

  38. exit(1);

  39. }

  40. ?
  41. bzero(&server_addr,0);

  42. server_addr.sin_family = AF_INET;

  43. server_addr.sin_port = htons(PORT);

  44. server_addr.sin_addr.s_addr = inet_addr("192.168.1.10");

  45. ?
  46. if(bind(sockfd,(struct sockaddr *)&server_addr,sizeof server_addr) < 0)

  47. {

  48. perror("bind error!\n");

  49. exit(1);

  50. }

  51. ?
  52. printf("bind success.............!\n");

  53. listen(sockfd,5);

  54. ?
  55. printf("listen success.............!\n");

  56. ?
  57. printf("accepting..................!\n");

  58. ?
  59. while(1)

  60. {

  61. ser_size = sizeof client_addr;

  62. ?
  63. if((new_fd = accept(sockfd,(struct sockaddr *)&client_addr,&ser_size)) < 0)

  64. {

  65. perror("accept error!\n");

  66. exit(1);

  67. }

  68. ?
  69. printf("accept success.................!\n");

  70. ?
  71. //read\recv

  72. ?
  73. printf("reading............!\n");

  74. n_read = read(new_fd,buffer,sizeof(buffer));

  75. ?
  76. if(n_read < 0)

  77. {

  78. perror("read client msg error!\n");

  79. exit(1);

  80. }

  81. ?
  82. buffer[n_read] = '\0';

  83. ?
  84. printf("recv msg = %s\n",buffer);

  85. }

  86. ?
  87. return 0;

  88. }

tcp_client.c

?

 
  1. #include <stdio.h>

  2. #include <string.h>

  3. #include <stdlib.h>

  4. ?
  5. #include <sys/types.h>

  6. #include <sys/socket.h>

  7. #include <netdb.h>

  8. ?
  9. #define PORT 3333

  10. #define MAX_SIZE 1024

  11. ?
  12. int main(int argc, char *argv[])

  13. {

  14. if(argc != 2)

  15. {

  16. printf("Please input server ip!\n");

  17. exit(1);

  18. }

  19. ?
  20. int sockfd;

  21. int n_write;

  22. ?
  23. struct sockaddr_in server_addr;

  24. ?
  25. char buffer[MAX_SIZE];

  26. ?
  27. if((sockfd = socket(AF_INET,SOCK_STREAM,0)) < 0)

  28. {

  29. perror("client socket error!\n");

  30. exit(1);

  31. }

  32. ?
  33. bzero(&server_addr,0);

  34. ?
  35. server_addr.sin_family = AF_INET;

  36. server_addr.sin_port = htons(PORT);

  37. server_addr.sin_addr.s_addr = inet_addr(argv[1]);

  38. ?
  39. if(connect(sockfd,(struct sockaddr *)&server_addr,sizeof server_addr) < 0)

  40. {

  41. perror("connect server error!\n");

  42. exit(1);

  43. }

  44. ?
  45. while(1)

  46. {

  47. memset(buffer,0,sizeof(buffer));

  48. printf("Please input send msg:\n");

  49. gets(buffer);

  50. ?
  51. n_write = write(sockfd,buffer,strlen(buffer));

  52. ?
  53. if(n_write == -1)

  54. {

  55. perror("send to server msg error!\n");

  56. exit(1);

  57. }

  58. }

  59. ?
  60. return 0;

  61. }

循環服務器能不斷地接收客戶端發送過來的信息,但是在面對多個客戶端時,服務器必須等待第一個客戶端發送信息才能接受其他客戶端發來的信息。

由此,我們使用并發服務器,通過創建子進程,使得多個客戶端能隨時發信息給服務器

并發服務器:

?

 
  1. #include <stdio.h>

  2. #include <stdlib.h>

  3. #include <string.h>

  4. ?
  5. #include <sys/types.h>

  6. #include <sys/socket.h>

  7. #include <sys/stat.h>

  8. #include <netdb.h>

  9. ?
  10. #define PORT 3333

  11. #define MAX_SIZE 1024

  12. ?
  13. void * read_msg(void *arg)

  14. {

  15. int n_read;

  16. ?
  17. int new_fd = *((int *)arg);

  18. ?
  19. char buffer[MAX_SIZE];

  20. ?
  21. printf("new_fd = %d\n",new_fd);

  22. ?
  23. while(1)

  24. {

  25. memset(buffer,0,sizeof(buffer));

  26. ?
  27. n_read = read(new_fd,buffer,sizeof(buffer));

  28. ?
  29. if(n_read < 0)

  30. {

  31. perror("recv client msg error!\n");

  32. exit(1);

  33. }

  34. ?
  35. if(n_read == 0)

  36. {

  37. printf("client is close!!\n");

  38. close(new_fd);

  39. pthread_exit(NULL);

  40. }

  41. ?
  42. buffer[n_read] = '\0';

  43. ?
  44. printf("recv msg:%s\n",buffer);

  45. }

  46. }

  47. ?
  48. int main()

  49. {

  50. int sockfd;

  51. int new_fd;

  52. ?
  53. struct sockaddr_in server_addr;

  54. struct sockaddr_in client_addr;

  55. ?
  56. int n_read;

  57. int ser_size;

  58. int opt = 1;

  59. ?
  60. char buffer[MAX_SIZE];

  61. ?
  62. pthread_t id;

  63. ?
  64. if((sockfd = socket(AF_INET,SOCK_STREAM,0)) < 0)

  65. {

  66. perror("socket error!\n");

  67. exit(1);

  68. }

  69. ?
  70. printf("socket success.............!\n");

  71. ?
  72. if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)) < 0)

  73. {

  74. perror("set socket option error!\n");

  75. exit(1);

  76. }

  77. ?
  78. bzero(&server_addr,0);

  79. server_addr.sin_family = AF_INET;

  80. server_addr.sin_port = htons(PORT);

  81. server_addr.sin_addr.s_addr = inet_addr("192.168.1.10");

  82. ?
  83. if(bind(sockfd,(struct sockaddr *)&server_addr,sizeof server_addr) < 0)

  84. {

  85. perror("bind error!\n");

  86. exit(1);

  87. }

  88. ?
  89. printf("bind success.............!\n");

  90. listen(sockfd,5);

  91. ?
  92. printf("listen success.............!\n");

  93. ?
  94. printf("accepting..................!\n");

  95. ?
  96. while(1)

  97. {

  98. ser_size = sizeof client_addr;

  99. ?
  100. if((new_fd = accept(sockfd,(struct sockaddr *)&client_addr,&ser_size)) < 0)

  101. {

  102. perror("accept error!\n");

  103. exit(1);

  104. }

  105. ?
  106. printf("accept success.................!\n");

  107. ?
  108. pthread_create(&id,NULL,read_msg,&new_fd);

  109. }

  110. ?
  111. return 0;

  112. }

并發客戶端:

?

 
  1. #include <stdio.h>

  2. #include <string.h>

  3. #include <stdlib.h>

  4. ?
  5. #include <sys/types.h>

  6. #include <sys/socket.h>

  7. #include <netdb.h>

  8. ?
  9. #define PORT 3333

  10. #define MAX_SIZE 1024

  11. ?
  12. int main(int argc, char *argv[])

  13. {

  14. if(argc != 2)

  15. {

  16. printf("Please input server ip!\n");

  17. exit(1);

  18. }

  19. ?
  20. int sockfd;

  21. int n_write;

  22. ?
  23. struct sockaddr_in server_addr;

  24. ?
  25. char buffer[MAX_SIZE];

  26. ?
  27. if((sockfd = socket(AF_INET,SOCK_STREAM,0)) < 0)

  28. {

  29. perror("client socket error!\n");

  30. exit(1);

  31. }

  32. ?
  33. bzero(&server_addr,0);

  34. ?
  35. server_addr.sin_family = AF_INET;

  36. server_addr.sin_port = htons(PORT);

  37. server_addr.sin_addr.s_addr = inet_addr(argv[1]);

  38. ?
  39. if(connect(sockfd,(struct sockaddr *)&server_addr,sizeof server_addr) < 0)

  40. {

  41. perror("connect server error!\n");

  42. exit(1);

  43. }

  44. ?
  45. while(1)

  46. {

  47. memset(buffer,0,sizeof(buffer));

  48. printf("Please input send msg:\n");

  49. gets(buffer);

  50. ?
  51. n_write = write(sockfd,buffer,strlen(buffer));

  52. ?
  53. if(n_write == -1)

  54. {

  55. perror("send to server msg error!\n");

  56. exit(1);

  57. }

  58. }

  59. ?
  60. return 0;

  61. }


并發服務器模型的缺點是:客戶端不再和服務器交互時,其多線程仍在工作,比較耗費CPU 的資源。

I/O多路轉接模型:

利用一個“監聽者”,當有客戶端發出連接請求及客戶端發送信息時,才會和服務器連接。

服務器代碼:

?

 
  1. #include <stdlib.h>

  2. #include <stdio.h>

  3. #include <errno.h>

  4. #include <string.h>

  5. #include <netdb.h>

  6. #include <sys/types.h>

  7. #include <netinet/in.h>

  8. #include <sys/socket.h>

  9. #include<unistd.h>

  10. #include<arpa/inet.h>

  11. #include<ctype.h>

  12. ?
  13. ?
  14. #define portnumber 8000

  15. ?
  16. #define MAX_LINE 80

  17. ?
  18. ?
  19. ?
  20. int main(void)

  21. {

  22. int lfd;

  23. int cfd;

  24. int sfd;

  25. int rdy;

  26. ?
  27. struct sockaddr_in sin;

  28. struct sockaddr_in cin;

  29. ?
  30. int client[FD_SETSIZE];

  31. ?
  32. int maxi;

  33. int maxfd;

  34. ?
  35. fd_set rset;

  36. fd_set allset;

  37. ?
  38. socklen_t addr_len;

  39. ?
  40. char buffer[MAX_LINE];

  41. ?
  42. int i;

  43. int n;

  44. int len;

  45. int opt = 1;

  46. ?
  47. char addr_p[20];

  48. ?
  49. ?
  50. bzero(&sin,sizeof(struct sockaddr_in));

  51. sin.sin_family=AF_INET;

  52. sin.sin_addr.s_addr=htonl(INADDR_ANY);

  53. sin.sin_port=htons(portnumber);

  54. ?
  55. ?
  56. if((lfd=socket(AF_INET,SOCK_STREAM,0))==-1)

  57. {

  58. fprintf(stderr,"Socket error:%s\n\a",strerror(errno));

  59. exit(1);

  60. }

  61. printf("socket!\n");

 
  1. ?
  2. setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));

  3. ?
  4. ?
  5. if(bind(lfd,(struct sockaddr *)(&sin),sizeof(struct sockaddr))==-1)

  6. {

  7. fprintf(stderr,"Bind error:%s\n\a",strerror(errno));

  8. exit(1);

  9. }

  10. printf("bind!\n");

  11. ?
  12. ?
  13. if(listen(lfd,20)==-1)

  14. {

  15. fprintf(stderr,"Listen error:%s\n\a",strerror(errno));

  16. exit(1);

  17. }

  18. printf("listen!\n");

  19. printf("Accepting connections .......\n");

  20. ?
  21. maxfd = lfd;

  22. maxi = -1;

  23. ?
  24. ?
  25. for(i = 0;i < FD_SETSIZE;i++)

  26. {

  27. client[i] = -1;

  28. }

  29. FD_ZERO(&allset);

  30. FD_SET(lfd,&allset);

  31. ?
  32. ?
  33. ?
  34. while(1)

  35. {

  36. rset = allset;

  37. printf("selecting!\n");

  38. ?
  39. rdy = select(maxfd + 1, &rset, NULL, NULL, NULL);

  40. ?
  41. printf("selected!\n");

  42. if(FD_ISSET(lfd, &rset))

  43. {

  44. ?
  45. addr_len = sizeof(sin);

  46. printf("accepting!\n");

  47. ?
  48. if((cfd=accept(lfd,(struct sockaddr *)(&cin),&addr_len))==-1)

  49. {

  50. fprintf(stderr,"Accept error:%s\n\a",strerror(errno));

  51. exit(1);

  52. }

  53. printf("accepted!\n");

  54. ?
  55. ?
  56. ?
  57. for(i = 0; i<FD_SETSIZE; i++)

  58. { //printf("%d\t",client[i]);

  59. if(client[i] <= 0)

  60. {

  61. client[i] = cfd;

  62. break;

  63. }

  64. }

  65. ?
  66. ?
  67. if(i == FD_SETSIZE)

  68. {

  69. printf("too many clients");

  70. exit(1);

  71. }

  72. ?
  73. FD_SET(cfd, &allset);

  74. ?
  75. if(cfd > maxfd)

  76. {

  77. maxfd = cfd;

  78. }

  79. ?
  80. if(i > maxi)

  81. {

  82. maxi = i;

  83. }

  84. ?
  85. if(--rdy <= 0)

  86. {

  87. continue;

  88. }

  89. ?
  90. }

  91. ?
  92. for(i = 0;i< FD_SETSIZE;i++)

  93. {

  94. if((sfd = client[i]) < 0)

  95. {

  96. continue;

  97. }

  98. ?
  99. if(FD_ISSET(sfd, &rset))

  100. {

  101. printf("reading!\n");

  102. n = read(sfd,buffer,MAX_LINE);

  103. printf("%s\n",buffer);

  104. printf("read!\n");

  105. if(n == 0)

  106. {

  107. printf("the other side has been closed. \n");

  108. fflush(stdout);

  109. close(sfd);

  110. ?
  111. FD_CLR(sfd, &allset);

  112. client[i] = -1;

  113. }

  114. ?
  115. else

  116. {

  117. ?
  118. inet_ntop(AF_INET, &cin.sin_addr, addr_p, sizeof(addr_p));

  119. addr_p[strlen(addr_p)] = '\0';

  120. ?
  121. ?
  122. printf("Client Ip is %s, port is %d\n",addr_p,ntohs(cin.sin_port));

  123. ?
  124. ?
  125. ?
  126. if(n == 1)

  127. {

  128. exit(1);

  129. }

  130. }

  131. ?
  132. ?
  133. if(--rdy <= 0)

  134. {

  135. break;

  136. ?
  137. ?
  138. }

  139. }

  140. ?
  141. }

  142. ?
  143. close(lfd);

  144. return 0;

  145. }

多路轉接客戶端:

?

 
  1. #include <stdlib.h>

  2. #include <stdio.h>

  3. #include <errno.h>

  4. #include <string.h>

  5. #include <netdb.h>

  6. #include <sys/types.h>

  7. #include <netinet/in.h>

  8. #include <sys/socket.h>

  9. ?
  10. #define portnumber 8000

  11. ?
  12. int main(int argc, char *argv[])

  13. {

  14. int nbytes;

  15. int sockfd;

  16. char buffer[80];

  17. char buffer_2[80];

  18. struct sockaddr_in server_addr;

  19. struct hostent *host;

  20. ?
  21. if(argc!=2)

  22. {

  23. fprintf(stderr,"Usage:%s hostname \a\n",argv[0]);

  24. exit(1);

  25. }

  26. ?
  27. if((host=gethostbyname(argv[1]))==NULL)

  28. {

  29. fprintf(stderr,"Gethostname error\n");

  30. exit(1);

  31. }

  32. ?
  33. ?
  34. if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1) // AF_INET:Internet;SOCK_STREAM:TCP

  35. {

  36. fprintf(stderr,"Socket Error:%s\a\n",strerror(errno));

  37. exit(1);

  38. }

  39. ?
  40. ?
  41. bzero(&server_addr,sizeof(server_addr)); //

  42. server_addr.sin_family=AF_INET;

  43. server_addr.sin_port=htons(portnumber);

  44. server_addr.sin_addr = *((struct in_addr *)host->h_addr);//址

  45. ?
  46. ?
  47. if(connect(sockfd,(struct sockaddr *)(&server_addr),sizeof(struct sockaddr))==-1)

  48. {

  49. fprintf(stderr,"Connect Error:%s\a\n",strerror(errno));

  50. exit(1);

  51. }

  52. ?
  53. while(1){

  54. ?
  55. printf("Please input char:\n");

  56. ?
  57. ?
  58. fgets(buffer,1024,stdin);

  59. write(sockfd,buffer,strlen(buffer));

  60. #if 0

  61. if((nbytes=read(sockfd,buffer_2,81))==-1)

  62. {

  63. fprintf(stderr,"Read Error:%s\n",strerror(errno));

  64. exit(1);

  65. }

  66. ?
  67. buffer_2[nbytes]='\0';

  68. printf("Client received from Server %s\n",buffer_2);

  69. #endif

  70. ?
  71. ?
  72. }

  73. close(sockfd);

  74. exit(0);

  75. }


?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/383644.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/383644.shtml
英文地址,請注明出處:http://en.pswp.cn/news/383644.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

c++繼承父類的子類,如何調用父類的同名函數?

https://blog.csdn.net/qq_26399665/article/details/52080215 子類調用父類的同名函數&#xff1a; 子類和父類返回值參數相同&#xff0c;函數名相同&#xff0c;有virtual關鍵字&#xff0c;則由對象的類型決定調用哪個函數。 子類和父類只要函數名相同&#xff0c;沒有vi…

LCS最長公共子串

問題介紹 LCS問題(longest common subsequence problem)指的是求解兩個字符串最長公共子序列問題。這里的子序列是可以不連續的。LCS問題廣泛地出現在計算生物學中&#xff08;DNA序列、系統生成樹等等&#xff09;。這里介紹如何解決LCS問題&#xff0c;以及算法的正確性證明…

將字符串中的空格用%20替換

如果不需要原地操作&#xff0c;則一遍遍歷&#xff0c;將非空串復制&#xff0c;遇到空格加上%20&#xff0c;如果需要原地操作&#xff0c;首先進行遍歷出空格的個數x,然后擴容2x,從后往前遍歷實現。如果非空格字符串比空格字符串多的多的時候而且字符串非常長的時候使用原地…

12步輕松搞定python裝飾器

http://python.jobbole.com/81683/ 呵呵&#xff01;作為一名教python的老師&#xff0c;我發現學生們基本上一開始很難搞定python的裝飾器&#xff0c;也許因為裝飾器確實很難懂。搞定裝飾器需要你了解一些函數式編程的概念&#xff0c;當然還有理解在python中定義和調用函數…

操作系統【六】虛擬內存

傳統存儲管理方式的不足 一次性&#xff1a;作業必須一次性全部裝入內存后才能開始運行。這會造成&#xff1a;當作也很大時不能全部裝入內存&#xff1b;當大量作業要求運行時&#xff0c;由于內存無法容納所有作業&#xff0c;因此只有少量作業能夠運行&#xff0c;導致多道…

python裝飾器詳解

https://blog.csdn.net/xiangxianghehe/article/details/77170585 你會Python嘛&#xff1f; 我會&#xff01; 那你給我講下Python裝飾器吧&#xff01; Python裝飾器啊&#xff1f;我沒用過哎 以上是我一個哥們面試時候發生的真實對白。 ———————————————-分…

SQL Server【一】簡介和基本概念和命令

數據結構和數據庫的區別 數據庫是應用軟件級別研究數據的存儲和操作&#xff08;主要針對磁盤上的數據&#xff09; 數據結構是在系統軟件級別研究數據的存儲和操作&#xff08;主要是針對內存中的數據&#xff09; 對硬盤數操作是數據庫的強項&#xff0c;是數據庫研究的核心…

SQL Server【二】單表查詢

查詢 計算列 select * from emp; -- *通配符&#xff0c;表示所有的字段 -- from emp 從emp表查詢select empno, ename from emp; select ename as "員工姓名", sal*12 as "年薪" from emp;-- as可以省略&#xff0c;用于設置字段名 -- 注意用雙引號將字…

SQL Server【三】連接查詢

將兩個表或者兩個以上的表以一定的連接條件連接起來&#xff0c;從中檢索出滿足條件的數據。 內連接 使用inner join&#xff0c;inner可以省略 -- 查詢員工的姓名和部門名稱 select "E".ename as "員工姓名", "D".dname as "部門名稱&q…

Linux下網絡socket編程——實現服務器(select)與多個客戶端通信

一、關于socket通信 服務器端工作流程&#xff1a; 調用 socket() 函數創建套接字 用 bind() 函數將創建的套接字與服務端IP地址綁定調用listen()函數監聽socket() 函數創建的套接字&#xff0c;等待客戶端連接 當客戶端請求到來之后調用 accept()函數接受連接請求&#xff0c…

SQL Server【四】

identity 主鍵自動增長&#xff0c;用戶不需要為identity修飾的主鍵賦值 create table student (std_id int primary key identity(10,5),--(10,5)可以省略&#xff0c;默認為(1,1)std_name nvarchar(200) not null ) select * from student insert into student values (張三…

TCP服務器/客戶端實例(C/C )

1.1、Linux下的TCP服務器&#xff1a; #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/types.h> #include <sys/socket.h>void error_handling(char *mess…

pip代理解決pip下載失敗問題

在用pip下載各種庫的時候發現速度實在是太慢了&#xff0c;還會有各種奇奇怪怪的問題&#xff0c;動不動就玄學失敗。 在網上找來找去找到知乎上一位大佬的回答&#xff1a;傳送門&#xff0c;用了豆瓣的代理。哇咔咔&#xff0c;媽媽再也不用擔心我下載失敗了。 代理&#x…

實現Linux select IO復用C/S服務器代碼

服務器端#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<string.h> #include<sys/socket.h> #include<sys/stat.h> #include<arpa/inet.h> #include <sys/select.h>#define MAXBUF 256 #define MAXLISTEN…

Bellman-Ford算法和SPFA算法

Belloman-Ford算法 算法介紹 Dijkstra可以解決單源無負邊最短路徑問題。但是當遇到含有負邊的單源最短路徑問題就需要使用Bellman-Ford算法來解決。Bellman-Ford算法還可以檢測出負環。 算法步驟 源點s,數組d[u]d[u]d[u]表示s到u的最短距離初始化&#xff1a;d[s]0d[s]0d[s…

C語言實現單鏈表操作

SLIST_H #ifndef __SLIST_H__ #define __SLIST_H__ #include<cstdio> #include<malloc.h> #include<assert.h> typedef int ElemType; typedef struct Node { //定義單鏈表中的結點信息 ElemType data; //結點的數據域 struct Node *next; //結點的指針…

計算機網絡【4】傳輸層

概述 傳輸層是只有主機才有的層次 傳輸層的功能&#xff1a; 傳輸層提供進程和進程之間的邏輯通信&#xff08;網絡層提供主機與主機之間的邏輯通信&#xff09;復用和分用傳輸層對收到的報文進行差錯檢測 傳輸層有兩個協議&#xff1a; 面向連接的傳輸層控制協議TCP&…

Plotly繪圖

在做Python數據分析實驗的時候發現使用Plotly庫繪圖比較漂亮&#xff0c;在網上找到了一個比較好的教程&#xff0c;這里記錄一下&#xff0c;方便以后查找。 傳送門

計算機網絡【0】概述

計算機網絡概念和功能 概念 是一個將分散的、具有獨立功能的計算機系統&#xff0c;通過通信設備與線路連接起來&#xff0c;由功能完善的軟件實現資源共享和信息傳遞的系統。 計算機網絡是互連的、自治&#xff08;無主從關系&#xff09;的計算機集合。 功能 數據通信&am…

計算機網絡【1】物理層

物理層解決如何在連接各種計算機的傳輸媒體上傳輸數據比特流&#xff0c;而不是指具體的傳輸媒體。 確定與傳輸媒體接口有關的特性 機械特性&#xff1a;定義物理連接的特性&#xff0c;如規格、接口形狀、引線數目、引腳數目、排列電氣特性&#xff1a;規定傳輸二進制位時的電…