{"id":50344,"date":"2025-07-30T23:01:37","date_gmt":"2025-07-30T15:01:37","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/50344.html"},"modified":"2025-07-30T23:01:37","modified_gmt":"2025-07-30T15:01:37","slug":"%e5%9f%ba%e4%ba%8e-linux-%e7%9a%84%e5%a4%9a%e7%ba%bf%e7%a8%8b%e8%af%8d%e5%85%b8%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8e%e5%ae%a2%e6%88%b7%e7%ab%af%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/50344.html","title":{"rendered":"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0"},"content":{"rendered":"<p>\u5728 Linux \u73af\u5883\u4e0b&#xff0c;\u5229\u7528 C \u8bed\u8a00\u5b9e\u73b0\u4e00\u4e2a\u652f\u6301\u591a\u7528\u6237\u5e76\u53d1\u8bbf\u95ee\u7684\u8bcd\u5178\u7cfb\u7edf\u662f\u4e00\u4e2a\u5f88\u6709\u610f\u4e49\u7684\u5b9e\u8df5\u9879\u76ee\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7 TCP socket \u901a\u4fe1\u3001\u591a\u7ebf\u7a0b\u7f16\u7a0b\u548c SQLite \u6570\u636e\u5e93&#xff0c;\u6784\u5efa\u4e00\u4e2a\u5305\u542b\u7528\u6237\u6ce8\u518c\u3001\u767b\u5f55\u3001\u5355\u8bcd\u67e5\u8be2\u53ca\u80cc\u8bcd\u672c\u529f\u80fd\u7684\u5b8c\u6574\u8bcd\u5178\u5e94\u7528\u3002<\/p>\n<h3>\u9879\u76ee\u6982\u8ff0<\/h3>\n<p>\u672c\u9879\u76ee\u7531\u4e09\u4e2a\u6838\u5fc3\u90e8\u5206\u7ec4\u6210&#xff1a;<\/p>\n<\/p>\n<ul>\n<li>\u670d\u52a1\u5668\u7aef&#xff08;finds.c&#xff09;&#xff1a;\u91c7\u7528\u591a\u7ebf\u7a0b\u6a21\u578b&#xff0c;\u652f\u6301\u591a\u5ba2\u6237\u7aef\u540c\u65f6\u8fde\u63a5&#xff0c;\u8d1f\u8d23\u5904\u7406\u7528\u6237\u8ba4\u8bc1\u3001\u5355\u8bcd\u67e5\u8be2\u3001\u5386\u53f2\u8bb0\u5f55\u5b58\u50a8\u7b49\u6838\u5fc3\u903b\u8f91<\/li>\n<li>\u5ba2\u6237\u7aef&#xff08;findc.c&#xff09;&#xff1a;\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u83dc\u5355\u754c\u9762&#xff0c;\u5b9e\u73b0\u4e0e\u670d\u52a1\u5668\u7684\u901a\u4fe1\u4ea4\u4e92<\/li>\n<li>\u5355\u8bcd\u5e93&#xff08;dict.txt&#xff09;&#xff1a;\u5b58\u50a8\u5355\u8bcd\u53ca\u91ca\u4e49\u7684\u6587\u672c\u6587\u4ef6<\/li>\n<\/ul>\n<p>\u6280\u672f\u6808&#xff1a;<\/p>\n<\/p>\n<ul>\n<li>\u7f51\u7edc\u901a\u4fe1&#xff1a;TCP socket<\/li>\n<li>\u5e76\u53d1\u5904\u7406&#xff1a;POSIX \u7ebf\u7a0b&#xff08;pthread&#xff09;<\/li>\n<li>\u6570\u636e\u5b58\u50a8&#xff1a;SQLite3 \u6570\u636e\u5e93<\/li>\n<li>\u5f00\u53d1\u73af\u5883&#xff1a;Linux&#xff08;Ubuntu&#xff09;<\/li>\n<\/ul>\n<h3>\u6838\u5fc3\u529f\u80fd\u8bbe\u8ba1<\/h3>\n<h4>1. \u7cfb\u7edf\u67b6\u6784<\/h4>\n<ul>\n<li>\u5ba2\u6237\u7aef &#8211; \u670d\u52a1\u5668\u6a21\u578b&#xff1a;\u57fa\u4e8e TCP \u534f\u8bae\u5b9e\u73b0\u53ef\u9760\u901a\u4fe1<\/li>\n<li>\u591a\u7ebf\u7a0b\u5e76\u53d1&#xff1a;\u670d\u52a1\u5668\u4e3a\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5\u521b\u5efa\u72ec\u7acb\u7ebf\u7a0b&#xff0c;\u5b9e\u73b0\u5e76\u53d1\u5904\u7406<\/li>\n<li>\u6570\u636e\u6301\u4e45\u5316&#xff1a;\u4f7f\u7528 SQLite3 \u5b58\u50a8\u7528\u6237\u4fe1\u606f\u548c\u67e5\u8be2\u5386\u53f2<\/li>\n<\/ul>\n<h4>2. \u6570\u636e\u5e93\u8bbe\u8ba1<\/h4>\n<p>\u521b\u5efa\u4e24\u4e2a\u6838\u5fc3\u8868&#xff1a;<\/p>\n<\/p>\n<p>sql<\/p>\n<p>&#8212; \u7528\u6237\u4fe1\u606f\u8868<br \/>\ncreate table if not exists usrinfo(<br \/>\n    name varchar(20),<br \/>\n    password varchar(20)<br \/>\n);<\/p>\n<p>&#8212; \u5386\u53f2\u67e5\u8be2\u8bb0\u5f55\u8868&#xff08;\u80cc\u8bcd\u672c&#xff09;<br \/>\ncreate table if not exists historyinfo(<br \/>\n    word varchar(20),<br \/>\n    name varchar(20),<br \/>\n    time varchar(20)<br \/>\n);<\/p>\n<h4>3. \u901a\u4fe1\u534f\u8bae\u8bbe\u8ba1<\/h4>\n<p>\u5b9a\u4e49\u6d88\u606f\u7ed3\u6784\u4f53MSG\u5b9e\u73b0\u6570\u636e\u4ea4\u4e92&#xff1a;<\/p>\n<\/p>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>typedef struct{<br \/>\n    int type;           \/\/ \u6d88\u606f\u7c7b\u578b&#xff08;R-\u6ce8\u518c\/L-\u767b\u5f55\/Q-\u67e5\u8be2\/H-\u5386\u53f2\/E-\u9000\u51fa&#xff09;<br \/>\n    char name[20];      \/\/ \u7528\u6237\u540d<br \/>\n    char data[256];     \/\/ \u6570\u636e&#xff08;\u5bc6\u7801\/\u5355\u8bcd\/\u91ca\u4e49&#xff09;<br \/>\n}MSG;<\/p>\n<h3>\u670d\u52a1\u5668\u7aef\u5b9e\u73b0&#xff08;finds.c&#xff09;<\/h3>\n<h4>1. \u591a\u7ebf\u7a0b\u5e76\u53d1\u5904\u7406<\/h4>\n<p>\u670d\u52a1\u5668\u901a\u8fc7pthread_create\u4e3a\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5\u521b\u5efa\u7ebf\u7a0b&#xff0c;\u6838\u5fc3\u4ee3\u7801&#xff1a;<\/p>\n<\/p>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>while(1){<br \/>\n    int newconfd &#061; accept(sfd, NULL, NULL);  \/\/ \u63a5\u6536\u5ba2\u6237\u7aef\u8fde\u63a5<br \/>\n    pthread_t id;<br \/>\n    pthread_create(&amp;id, NULL, dealclient, &amp;newconfd);  \/\/ \u521b\u5efa\u7ebf\u7a0b<br \/>\n    pthread_detach(id);  \/\/ \u5206\u79bb\u7ebf\u7a0b&#xff0c;\u81ea\u52a8\u56de\u6536\u8d44\u6e90<br \/>\n}<\/p>\n<p>\u7ebf\u7a0b\u5904\u7406\u51fd\u6570dealclient\u5faa\u73af\u8bfb\u53d6\u5ba2\u6237\u7aef\u6d88\u606f&#xff0c;\u6839\u636e\u6d88\u606f\u7c7b\u578b\u5206\u53d1\u5904\u7406&#xff1a;<\/p>\n<\/p>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>void* dealclient(void* p){<br \/>\n    int newconfd &#061; *(int*)p;<br \/>\n    MSG m;<br \/>\n    while(1){<br \/>\n        read(newconfd, &amp;m, sizeof(m));  \/\/ \u8bfb\u53d6\u6d88\u606f<br \/>\n        switch(m.type){<br \/>\n            case E: dealexit(&amp;m, newconfd); break;<br \/>\n            case R: dealregister(&amp;m, newconfd); break;<br \/>\n            case L: deallogin(newconfd, &amp;m); break;<br \/>\n            case Q: dealquery(newconfd, &amp;m); break;<br \/>\n            case H: dealhistory(newconfd, &amp;m); break;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>2. \u6838\u5fc3\u529f\u80fd\u6a21\u5757<\/h4>\n<h5>&#xff08;1&#xff09;\u7528\u6237\u6ce8\u518c\u4e0e\u767b\u5f55<\/h5>\n<ul>\n<li>\u6ce8\u518c\u65f6\u68c0\u67e5\u7528\u6237\u540d\u552f\u4e00\u6027&#xff0c;\u901a\u8fc7sqlite3_get_table\u67e5\u8be2\u7528\u6237\u662f\u5426\u5b58\u5728<\/li>\n<li>\u767b\u5f55\u65f6\u9a8c\u8bc1\u7528\u6237\u540d\u548c\u5bc6\u7801&#xff0c;\u6210\u529f\u540e\u8fd4\u56de\u767b\u5f55\u72b6\u6001<\/li>\n<\/ul>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6ce8\u518c\u5904\u7406\u793a\u4f8b<br \/>\nvoid dealregister(MSG *pm, int newconfd){<br \/>\n    char sql[100];<br \/>\n    char **result &#061; NULL;<br \/>\n    int row, col;<br \/>\n    sprintf(sql, &#034;select *from usrinfo where name&#061;&#039;%s&#039;;&#034;, pm-&gt;name);<br \/>\n    sqlite3_get_table(db, sql, &amp;result, &amp;row, &amp;col, NULL);<br \/>\n    if(!row){  \/\/ \u7528\u6237\u540d\u4e0d\u5b58\u5728&#xff0c;\u5141\u8bb8\u6ce8\u518c<br \/>\n        sprintf(sql, &#034;insert into usrinfo values(&#039;%s&#039;,&#039;%s&#039;)&#034;, pm-&gt;name, pm-&gt;data);<br \/>\n        sqlite3_exec(db, sql, NULL, NULL, NULL);<br \/>\n        strcpy(pm-&gt;data, &#034;\u6ce8\u518c\u6210\u529f&#034;);<br \/>\n    }else{<br \/>\n        strcpy(pm-&gt;data, &#034;\u7528\u6237\u5df2\u5b58\u5728&#034;);<br \/>\n    }<br \/>\n    sqlite3_free_table(result);  \/\/ \u91ca\u653e\u7ed3\u679c\u96c6&#xff0c;\u907f\u514d\u5185\u5b58\u6cc4\u6f0f<br \/>\n    write(newconfd, pm, sizeof(MSG));<br \/>\n}<\/p>\n<h5>&#xff08;2&#xff09;\u5355\u8bcd\u67e5\u8be2\u4e0e\u5386\u53f2\u8bb0\u5f55<\/h5>\n<ul>\n<li>\u4ecedict.txt\u4e2d\u67e5\u8be2\u5355\u8bcd&#xff0c;\u4f7f\u7528strncmp\u8fdb\u884c\u9ad8\u6548\u5339\u914d<\/li>\n<li>\u67e5\u8be2\u6210\u529f\u540e\u81ea\u52a8\u8bb0\u5f55\u5230\u5386\u53f2\u8868&#xff0c;\u5305\u542b\u5355\u8bcd\u3001\u7528\u6237\u540d\u548c\u67e5\u8be2\u65f6\u95f4<\/li>\n<\/ul>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u5355\u8bcd\u67e5\u8be2\u5904\u7406<br \/>\nvoid dealquery(int newconfd, MSG *pm){<br \/>\n    char sql[100];<br \/>\n    int ret &#061; searchword(pm-&gt;data);  \/\/ \u4ece\u8bcd\u5178\u6587\u4ef6\u67e5\u8be2<br \/>\n    if(ret){  \/\/ \u67e5\u8be2\u6210\u529f<br \/>\n        time_t t &#061; time(NULL);<br \/>\n        char *ptime &#061; ctime(&amp;t);<br \/>\n        \/\/ \u63d2\u5165\u5386\u53f2\u8bb0\u5f55<br \/>\n        sprintf(sql, &#034;insert into historyinfo values(&#039;%s&#039;,&#039;%s&#039;,&#039;%s&#039;);&#034;,<br \/>\n                pm-&gt;data, pm-&gt;name, ptime);<br \/>\n        sqlite3_exec(db, sql, NULL, NULL, NULL);<br \/>\n    }else{<br \/>\n        strcpy(pm-&gt;data, &#034;\u5355\u8bcd\u4e0d\u5b58\u5728&#034;);<br \/>\n    }<br \/>\n    write(newconfd, pm, sizeof(MSG));<br \/>\n}<\/p>\n<h5>&#xff08;3&#xff09;\u80cc\u8bcd\u672c&#xff08;\u5386\u53f2\u8bb0\u5f55&#xff09;\u67e5\u8be2<\/h5>\n<ul>\n<li>\u6309\u7528\u6237\u540d\u67e5\u8be2\u5386\u53f2\u8bb0\u5f55&#xff0c;\u901a\u8fc7\u5faa\u73af\u53d1\u9001\u591a\u6761\u8bb0\u5f55&#xff0c;\u5e76\u4ee5sendover\u6807\u8bb0\u7ed3\u675f<\/li>\n<li>\u4f7f\u7528usleep(3)\u907f\u514d TCP \u7c98\u5305\u95ee\u9898<\/li>\n<\/ul>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>void dealhistory(int newconfd, MSG *pm){<br \/>\n    char sql[100];<br \/>\n    sprintf(sql, &#034;select *from historyinfo where name&#061;&#039;%s&#039;;&#034;, pm-&gt;name);<br \/>\n    char **result &#061; NULL;<br \/>\n    int row, col;<br \/>\n    sqlite3_get_table(db, sql, &amp;result, &amp;row, &amp;col, NULL);<br \/>\n    if(row){  \/\/ \u6709\u67e5\u8be2\u8bb0\u5f55<br \/>\n        for(int i&#061;0; i&lt;(row&#043;1)*col; i&#043;&#043;){  \/\/ \u5faa\u73af\u53d1\u9001\u8bb0\u5f55<br \/>\n            strcpy(pm-&gt;data, result[i]);<br \/>\n            write(newconfd, pm, sizeof(MSG));<br \/>\n            usleep(3);  \/\/ \u907f\u514d\u7c98\u5305<br \/>\n        }<br \/>\n        strcpy(pm-&gt;data, &#034;sendover&#034;);  \/\/ \u53d1\u9001\u7ed3\u675f\u6807\u8bb0<br \/>\n        write(newconfd, pm, sizeof(MSG));<br \/>\n    }<br \/>\n    sqlite3_free_table(result);<br \/>\n}<\/p>\n<h3>\u5ba2\u6237\u7aef\u5b9e\u73b0&#xff08;findc.c&#xff09;<\/h3>\n<h4>1. \u4ea4\u4e92\u754c\u9762\u8bbe\u8ba1<\/h4>\n<ul>\n<li>\u4e00\u7ea7\u83dc\u5355&#xff1a;\u6ce8\u518c\u3001\u767b\u5f55\u3001\u9000\u51fa<\/li>\n<li>\u4e8c\u7ea7\u83dc\u5355&#xff08;\u767b\u5f55\u540e&#xff09;&#xff1a;\u67e5\u5355\u8bcd\u3001\u80cc\u8bcd\u672c\u3001\u9000\u51fa<\/li>\n<\/ul>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u4e8c\u7ea7\u83dc\u5355\u793a\u4f8b<br \/>\nvoid show(int cfd, MSG* pm){<br \/>\n    int choose;<br \/>\n    while(1){<br \/>\n        puts(&#034;1\u67e5\u5355\u8bcd\u30002\u80cc\u8bcd\u672c\u30003\u9000\u51fa&#034;);<br \/>\n        scanf(&#034;%d&#034;, &amp;choose);<br \/>\n        switch(choose){<br \/>\n            case 1: dealquery(cfd, pm); break;<br \/>\n            case 2: dealhistory(cfd, pm); break;<br \/>\n            case 3: dealexit(cfd); exit(0);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>2. \u5355\u8bcd\u67e5\u8be2\u6d41\u7a0b<\/h4>\n<ul>\n<li>\u5faa\u73af\u8f93\u5165\u5355\u8bcd&#xff08;\u6309#\u7ed3\u675f&#xff09;&#xff0c;\u53d1\u9001\u67e5\u8be2\u8bf7\u6c42<\/li>\n<li>\u63a5\u6536\u5e76\u663e\u793a\u670d\u52a1\u5668\u8fd4\u56de\u7684\u5355\u8bcd\u91ca\u4e49<\/li>\n<\/ul>\n<p>c<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>void dealquery(int cfd, MSG* pm){<br \/>\n    pm-&gt;type &#061; Q;<br \/>\n    while(1){<br \/>\n        puts(&#034;\u8bf7\u8f93\u5165\u8981\u67e5\u8be2\u7684\u5355\u8bcd\u6309&#xff03;\u7ed3\u675f&#034;);<br \/>\n        scanf(&#034;%s&#034;, pm-&gt;data);<br \/>\n        if(!strcmp(pm-&gt;data, &#034;#&#034;)) break;<br \/>\n        write(cfd, pm, sizeof(MSG));<br \/>\n        read(cfd, pm, sizeof(MSG));<br \/>\n        puts(pm-&gt;data);  \/\/ \u663e\u793a\u67e5\u8be2\u7ed3\u679c<br \/>\n    }<br \/>\n}<\/p>\n<h3>\u7f16\u8bd1\u4e0e\u8fd0\u884c<\/h3>\n<h4>\u670d\u52a1\u5668\u7f16\u8bd1<\/h4>\n<p>\u9700\u8981\u94fe\u63a5 SQLite3 \u548c pthread \u5e93&#xff1a;<\/p>\n<\/p>\n<p>bash<\/p>\n<p>gcc finds.c -o server -lsqlite3 -lpthread<\/p>\n<h4>\u5ba2\u6237\u7aef\u7f16\u8bd1<\/h4>\n<p>bash<\/p>\n<p>gcc findc.c -o client<\/p>\n<h4>\u8fd0\u884c\u6b65\u9aa4<\/h4>\n<li>\u542f\u52a8\u670d\u52a1\u5668&#xff08;\u6307\u5b9a\u7aef\u53e3&#xff09;&#xff1a;\n<p>bash<\/p>\n<p>.\/server 8888<\/p>\n<\/li>\n<li>\u542f\u52a8\u5ba2\u6237\u7aef&#xff08;\u6307\u5b9a\u670d\u52a1\u5668 IP \u548c\u7aef\u53e3&#xff09;&#xff1a;\n<p>bash<\/p>\n<p>.\/client 127.0.0.1 8888<\/p>\n<\/li>\n<h3>\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h3>\n<li>\n<p>SQLite3 \u5185\u5b58\u6cc4\u6f0f<br \/>\n\u6bcf\u6b21\u4f7f\u7528sqlite3_get_table\u540e\u5fc5\u987b\u8c03\u7528sqlite3_free_table\u91ca\u653e\u7ed3\u679c\u96c6<\/p>\n<\/li>\n<li>\n<p>TCP \u7c98\u5305\u95ee\u9898<br \/>\n\u901a\u8fc7usleep(3)\u5728\u8fde\u7eed\u53d1\u9001\u591a\u6761\u8bb0\u5f55\u65f6\u6dfb\u52a0\u5fae\u5c0f\u5ef6\u8fdf<\/p>\n<\/li>\n<li>\n<p>\u591a\u7ebf\u7a0b\u6570\u636e\u5e93\u5b89\u5168<br \/>\n\u4f7f\u7528\u5168\u5c40\u6570\u636e\u5e93\u8fde\u63a5\u65f6&#xff0c;\u786e\u4fdd SQLite \u7f16\u8bd1\u65f6\u5f00\u542f\u7ebf\u7a0b\u5b89\u5168\u9009\u9879&#xff08;\u9ed8\u8ba4\u5f00\u542f&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u672a\u5b9a\u4e49\u5f15\u7528\u9519\u8bef<br \/>\n\u7f16\u8bd1\u65f6\u5fd8\u8bb0\u94fe\u63a5\u5e93\u4f1a\u5bfc\u81f4undefined reference&#xff0c;\u9700\u6dfb\u52a0-lsqlite3 -lpthread<\/p>\n<\/li>\n<h3>\u603b\u7ed3\u4e0e\u6269\u5c55<\/h3>\n<p>\u672c\u9879\u76ee\u5b9e\u73b0\u4e86\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684\u8bcd\u5178\u7cfb\u7edf&#xff0c;\u5305\u542b\u7528\u6237\u8ba4\u8bc1\u3001\u5355\u8bcd\u67e5\u8be2\u548c\u5386\u53f2\u8bb0\u5f55\u7ba1\u7406\u3002\u53ef\u8fdb\u4e00\u6b65\u6269\u5c55\u7684\u529f\u80fd&#xff1a;<\/p>\n<\/p>\n<ul>\n<li>\u6dfb\u52a0\u5bc6\u7801\u52a0\u5bc6\u5b58\u50a8&#xff08;\u5982 MD5 \u54c8\u5e0c&#xff09;<\/li>\n<li>\u5b9e\u73b0\u5355\u8bcd\u672c\u5206\u9875\u67e5\u8be2<\/li>\n<li>\u589e\u52a0\u5355\u8bcd\u53d1\u97f3\u529f\u80fd<\/li>\n<li>\u4f18\u5316\u8bcd\u5178\u67e5\u8be2\u7b97\u6cd5&#xff08;\u5982\u4e8c\u5206\u67e5\u627e&#xff09;<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u9879\u76ee&#xff0c;\u4e0d\u4ec5\u80fd\u638c\u63e1 Linux \u7f51\u7edc\u7f16\u7a0b\u548c\u591a\u7ebf\u7a0b\u6280\u672f&#xff0c;\u8fd8\u80fd\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef &#8211; \u670d\u52a1\u5668\u67b6\u6784\u548c\u6570\u636e\u5e93\u5e94\u7528&#xff0c;\u4e3a\u66f4\u590d\u6742\u7684\u7f51\u7edc\u5e94\u7528\u5f00\u53d1\u6253\u4e0b\u57fa\u7840\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb924\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u57fa\u4e8eLinux\u73af\u5883\u7684C\u8bed\u8a00\u8bcd\u5178\u7cfb\u7edf\u5b9e\u73b0\u65b9\u6848\u3002\u8be5\u7cfb\u7edf\u91c7\u7528\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u67b6\u6784\uff0c\u652f\u6301\u591a\u7528\u6237\u5e76\u53d1\u8bbf\u95ee\uff0c\u4e3b\u8981\u529f\u80fd\u5305\u62ec\u7528\u6237\u6ce8\u518c\u767b\u5f55\u3001\u5355\u8bcd\u67e5\u8be2\u548c\u80cc\u8bcd\u672c\u7ba1\u7406\u3002\u670d\u52a1\u5668\u7aef\u4f7f\u7528\u591a\u7ebf\u7a0b\u5904\u7406\u5e76\u53d1\u8bf7\u6c42\uff0cTCP socket\u5b9e\u73b0\u901a\u4fe1\uff0cSQLite3\u5b58\u50a8\u7528\u6237\u6570\u636e\uff1b\u5ba2\u6237\u7aef\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u83dc\u5355\u754c\u9762\u3002\u6280\u672f\u6838\u5fc3\u5305\u62ec\uff1apthread\u591a\u7ebf\u7a0b\u6a21\u578b\u5904\u7406\u5e76\u53d1\u8fde\u63a5\u3001SQLite\u6570\u636e\u5e93\u5b58\u50a8\u7528\u6237\u4fe1\u606f\u548c\u67e5\u8be2\u5386\u53f2\u3001\u81ea\u5b9a\u4e49\u901a\u4fe1\u534f\u8bae\u8fdb\u884c\u6570\u636e\u4ea4\u4e92\u3002\u9879\u76ee\u5b9e\u73b0\u4e86\u4ece\u8bcd\u5178\u6587\u4ef6\u9ad8\u6548\u67e5\u8be2\u5355\u8bcd\u3001\u81ea\u52a8\u8bb0\u5f55\u67e5\u8be2\u5386\u53f2\u7b49\u529f\u80fd\uff0c\u5e76\u89e3\u51b3\u4e86TCP\u7c98\u5305\u3001\u5185\u5b58\u6cc4\u6f0f\u7b49\u5b9e\u9645\u95ee\u9898\uff0c\u4e3a\u7f51\u7edc\u5e94\u7528\u5f00\u53d1\u63d0\u4f9b\u4e86<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,43,44],"topic":[],"class_list":["post-50344","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/50344.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb924\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u57fa\u4e8eLinux\u73af\u5883\u7684C\u8bed\u8a00\u8bcd\u5178\u7cfb\u7edf\u5b9e\u73b0\u65b9\u6848\u3002\u8be5\u7cfb\u7edf\u91c7\u7528\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u67b6\u6784\uff0c\u652f\u6301\u591a\u7528\u6237\u5e76\u53d1\u8bbf\u95ee\uff0c\u4e3b\u8981\u529f\u80fd\u5305\u62ec\u7528\u6237\u6ce8\u518c\u767b\u5f55\u3001\u5355\u8bcd\u67e5\u8be2\u548c\u80cc\u8bcd\u672c\u7ba1\u7406\u3002\u670d\u52a1\u5668\u7aef\u4f7f\u7528\u591a\u7ebf\u7a0b\u5904\u7406\u5e76\u53d1\u8bf7\u6c42\uff0cTCP socket\u5b9e\u73b0\u901a\u4fe1\uff0cSQLite3\u5b58\u50a8\u7528\u6237\u6570\u636e\uff1b\u5ba2\u6237\u7aef\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u83dc\u5355\u754c\u9762\u3002\u6280\u672f\u6838\u5fc3\u5305\u62ec\uff1apthread\u591a\u7ebf\u7a0b\u6a21\u578b\u5904\u7406\u5e76\u53d1\u8fde\u63a5\u3001SQLite\u6570\u636e\u5e93\u5b58\u50a8\u7528\u6237\u4fe1\u606f\u548c\u67e5\u8be2\u5386\u53f2\u3001\u81ea\u5b9a\u4e49\u901a\u4fe1\u534f\u8bae\u8fdb\u884c\u6570\u636e\u4ea4\u4e92\u3002\u9879\u76ee\u5b9e\u73b0\u4e86\u4ece\u8bcd\u5178\u6587\u4ef6\u9ad8\u6548\u67e5\u8be2\u5355\u8bcd\u3001\u81ea\u52a8\u8bb0\u5f55\u67e5\u8be2\u5386\u53f2\u7b49\u529f\u80fd\uff0c\u5e76\u89e3\u51b3\u4e86TCP\u7c98\u5305\u3001\u5185\u5b58\u6cc4\u6f0f\u7b49\u5b9e\u9645\u95ee\u9898\uff0c\u4e3a\u7f51\u7edc\u5e94\u7528\u5f00\u53d1\u63d0\u4f9b\u4e86\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/50344.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T15:01:37+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50344.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/50344.html\",\"name\":\"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T15:01:37+00:00\",\"dateModified\":\"2025-07-30T15:01:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/50344.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/50344.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50344.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/50344.html","og_locale":"zh_CN","og_type":"article","og_title":"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb924\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u57fa\u4e8eLinux\u73af\u5883\u7684C\u8bed\u8a00\u8bcd\u5178\u7cfb\u7edf\u5b9e\u73b0\u65b9\u6848\u3002\u8be5\u7cfb\u7edf\u91c7\u7528\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u67b6\u6784\uff0c\u652f\u6301\u591a\u7528\u6237\u5e76\u53d1\u8bbf\u95ee\uff0c\u4e3b\u8981\u529f\u80fd\u5305\u62ec\u7528\u6237\u6ce8\u518c\u767b\u5f55\u3001\u5355\u8bcd\u67e5\u8be2\u548c\u80cc\u8bcd\u672c\u7ba1\u7406\u3002\u670d\u52a1\u5668\u7aef\u4f7f\u7528\u591a\u7ebf\u7a0b\u5904\u7406\u5e76\u53d1\u8bf7\u6c42\uff0cTCP socket\u5b9e\u73b0\u901a\u4fe1\uff0cSQLite3\u5b58\u50a8\u7528\u6237\u6570\u636e\uff1b\u5ba2\u6237\u7aef\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u83dc\u5355\u754c\u9762\u3002\u6280\u672f\u6838\u5fc3\u5305\u62ec\uff1apthread\u591a\u7ebf\u7a0b\u6a21\u578b\u5904\u7406\u5e76\u53d1\u8fde\u63a5\u3001SQLite\u6570\u636e\u5e93\u5b58\u50a8\u7528\u6237\u4fe1\u606f\u548c\u67e5\u8be2\u5386\u53f2\u3001\u81ea\u5b9a\u4e49\u901a\u4fe1\u534f\u8bae\u8fdb\u884c\u6570\u636e\u4ea4\u4e92\u3002\u9879\u76ee\u5b9e\u73b0\u4e86\u4ece\u8bcd\u5178\u6587\u4ef6\u9ad8\u6548\u67e5\u8be2\u5355\u8bcd\u3001\u81ea\u52a8\u8bb0\u5f55\u67e5\u8be2\u5386\u53f2\u7b49\u529f\u80fd\uff0c\u5e76\u89e3\u51b3\u4e86TCP\u7c98\u5305\u3001\u5185\u5b58\u6cc4\u6f0f\u7b49\u5b9e\u9645\u95ee\u9898\uff0c\u4e3a\u7f51\u7edc\u5e94\u7528\u5f00\u53d1\u63d0\u4f9b\u4e86","og_url":"https:\/\/www.wsisp.com\/helps\/50344.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T15:01:37+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/50344.html","url":"https:\/\/www.wsisp.com\/helps\/50344.html","name":"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T15:01:37+00:00","dateModified":"2025-07-30T15:01:37+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/50344.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/50344.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/50344.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u57fa\u4e8e Linux \u7684\u591a\u7ebf\u7a0b\u8bcd\u5178\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=50344"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50344\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=50344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=50344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=50344"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=50344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}