{"id":2260,"date":"2018-08-22T14:03:09","date_gmt":"2018-08-22T06:03:09","guid":{"rendered":"http:\/\/www.51cos.com\/?p=2260"},"modified":"2018-08-22T14:20:57","modified_gmt":"2018-08-22T06:20:57","slug":"%e6%9c%ac%e5%9c%b0socket%e9%80%9a%e8%ae%af%e4%b8%8e%e7%bd%91%e7%bb%9csocket%e9%80%9a%e8%ae%af","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=2260","title":{"rendered":"\u672c\u5730socket\u901a\u8baf\u4e0e\u7f51\u7edcsocket\u901a\u8baf"},"content":{"rendered":"<p>\n https:\/\/blog.csdn.net\/u012662731\/article\/details\/53747860  <\/p>\n<p>\u5728\u4f7f\u7528\u8fdb\u7a0b\u95f4\u901a\u4fe1\u5f80\u5f80\u7528\u7684\u4e0d\u662f\u7f51\u7edc\u5957\u63a5\u5b57\uff0c\u800c\u662f\u4e00\u79cd\u79f0\u4e3a\u672c\u5730\u5957\u63a5\u5b57\u7684\u65b9\u5f0f\u3002<\/p>\n<p>socket API\u539f\u672c\u662f\u4e3a\u7f51\u7edc\u901a\u8baf\u8bbe\u8ba1\u7684\uff0c\u4f46\u540e\u6765\u5728socket\u7684\u6846\u67b6\u4e0a\u53d1\u5c55\u51fa\u4e00\u79cdIPC\u673a\u5236\uff0c\u5c31\u662fUNIX Domain Socket\u3002\u867d\u7136\u7f51\u7edcsocket\u4e5f\u53ef\u7528\u4e8e\u540c\u4e00\u53f0\u4e3b\u673a\u7684\u8fdb\u7a0b\u95f4\u901a\u8baf\uff08\u901a\u8fc7loopback\u5730\u5740127.0.0.1\uff09\uff0c\u4f46\u662fUNIX Domain Socket\u7528\u4e8eIPC\u66f4\u6709\u6548\u7387\uff1a\u4e0d\u9700\u8981\u7ecf\u8fc7\u7f51\u7edc\u534f\u8bae\u6808\uff0c\u4e0d\u9700\u8981\u6253\u5305\u62c6\u5305\u3001\u8ba1\u7b97\u6821\u9a8c\u548c\u3001\u7ef4\u62a4\u5e8f\u53f7\u548c\u5e94\u7b54\u7b49\uff0c\u53ea\u662f\u5c06\u5e94\u7528\u5c42\u6570\u636e\u4ece\u4e00\u4e2a\u8fdb\u7a0b\u62f7\u8d1d\u5230\u53e6\u4e00\u4e2a\u8fdb\u7a0b\u3002UNIX Domain Socket\u4e5f\u63d0\u4f9b\u9762\u5411\u6d41\u548c\u9762\u5411\u6570\u636e\u5305\u4e24\u79cdAPI\u63a5\u53e3\uff0c\u7c7b\u4f3c\u4e8eTCP\u548cUDP\u3002<\/p>\n<p>\u4f7f\u7528UNIX Domain Socket\u7684\u8fc7\u7a0b\u548c\u7f51\u7edcsocket\u5341\u5206\u76f8\u4f3c\uff0c\u4e5f\u8981\u5148\u8c03\u7528socket()\u521b\u5efa\u4e00\u4e2asocket\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0caddress family\u6307\u5b9a\u4e3aAF_UNIX\uff0ctype\u53ef\u4ee5\u9009\u62e9SOCK_DGRAM\u6216SOCK_STREAM\uff0cprotocol\u53c2\u6570\u4ecd\u7136\u6307\u5b9a\u4e3a0\u5373\u53ef\u3002<\/p>\n<p>UNIX Domain Socket\u4e0e\u7f51\u7edcsocket\u7f16\u7a0b\u6700\u660e\u663e\u7684\u4e0d\u540c\u5728\u4e8e\u5730\u5740\u683c\u5f0f\u4e0d\u540c\uff0c\u7528\u7ed3\u6784\u4f53sockaddr_un\u8868\u793a\uff0c\u7f51\u7edc\u7f16\u7a0b\u7684socket\u5730\u5740\u662fIP\u5730\u5740\u52a0\u7aef\u53e3\u53f7\uff0c\u800cUNIX Domain Socket\u7684\u5730\u5740\u662f\u4e00\u4e2asocket\u7c7b\u578b\u7684\u6587\u4ef6\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\uff0c\u8fd9\u4e2asocket\u6587\u4ef6\u7531bind()\u8c03\u7528\u521b\u5efa\uff0c\u5982\u679c\u8c03\u7528bind()\u65f6\u8be5\u6587\u4ef6\u5df2\u5b58\u5728\uff0c\u5219bind()\u9519\u8bef\u8fd4\u56de\u3002<\/p>\n<pre class=\"lang:default decode:true \">\u670d\u52a1\u5668\u7aef\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>1. socket\uff1a      \u5efa\u7acb\u4e00\u4e2asocket<br \/>\n2. bind\uff1a          \u5c06\u8fd9\u4e2asocket\u7ed1\u5b9a\u5728\u67d0\u4e2a\u6587\u4ef6\u4e0a\uff08AF_UNIX\uff09\u6216\u67d0\u4e2a\u7aef\u53e3\u4e0a\uff08AF_INET\uff09\uff0c\u6211\u4eec\u4f1a\u5206\u522b\u4ecb\u7ecd\u8fd9\u4e24\u79cd\u3002<br \/>\n3. listen\uff1a        \u5f00\u59cb\u76d1\u542c<br \/>\n4. accept\uff1a      \u5982\u679c\u76d1\u542c\u5230\u5ba2\u6237\u7aef\u8fde\u63a5\uff0c\u5219\u8c03\u7528accept\u63a5\u6536\u8fd9\u4e2a\u8fde\u63a5\u5e76\u540c\u65f6\u65b0\u5efa\u4e00\u4e2asocket\u6765\u548c\u5ba2\u6237\u8fdb\u884c\u901a\u4fe1<br \/>\n5. read\/write\uff1a\u8bfb\u53d6\u6216\u53d1\u9001\u6570\u636e\u5230\u5ba2\u6237\u7aef<br \/>\n6. close\uff1a        \u901a\u4fe1\u5b8c\u6210\u540e\u5173\u95edsocket<\/p>\n<p>\u5ba2\u6237\u7aef\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<br \/>\n1. socket\uff1a      \u5efa\u7acb\u4e00\u4e2asocket<br \/>\n2. connect\uff1a   \u4e3b\u52a8\u8fde\u63a5\u670d\u52a1\u5668\u7aef\u7684\u67d0\u4e2a\u6587\u4ef6\uff08AF_UNIX\uff09\u6216\u67d0\u4e2a\u7aef\u53e3\uff08AF_INET\uff09<br \/>\n3. read\/write\uff1a\u5982\u679c\u670d\u52a1\u5668\u540c\u610f\u8fde\u63a5\uff08accept\uff09\uff0c\u5219\u8bfb\u53d6\u6216\u53d1\u9001\u6570\u636e\u5230\u670d\u52a1\u5668\u7aef<br \/>\n4. close\uff1a        \u901a\u4fe1\u5b8c\u6210\u540e\u5173\u95edsocket<\/p>\n<pre class=\"lang:default decode:true \">\u5148\u7ed9\u51fa\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5177\u4f53\u5206\u6790\u4f1a\u5728\u4e4b\u540e\u7ed9\u51fa\u3002\u4f8b\u5b50\u5b9e\u73b0\u7684\u529f\u80fd\u662f\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2a\u5b57\u7b26\u5230\u670d\u52a1\u5668\uff0c\u670d\u52a1\u5668\u5c06\u8fd9\u4e2a\u5b57\u7b26+1\u540e\u9001\u56de\u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u518d\u628a\u5b83\u6253\u5370\u51fa\u6765\uff1a<br \/>\nMakefile\uff1a<\/p>\n<p>all: tcp_client.c tcp_server.c<br \/>\n    gcc -g -Wall -o tcp_client tcp_client.c<br \/>\n    gcc -g -Wall -o tcp_server tcp_server.c<br \/>\nclean:<br \/>\n    rm -rf *.o tcp_client tcp_server <\/p>\n<pre class=\"lang:default decode:true \">\/\/tcp_server.c\uff1a<\/p>\n<p>#include<br \/>\n#include<br \/>\n#include<br \/>\n#include<br \/>\n#include<br \/>\n#include   <\/p>\n<p>int main()<br \/>\n{<br \/>\n  \/* delete the socket file *\/<br \/>\n  unlink(\"server_socket\");  <\/p>\n<p>  \/* create a socket *\/<br \/>\n  int server_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);  <\/p>\n<p>  struct sockaddr_un server_addr;<br \/>\n  server_addr.sun_family = AF_UNIX;<br \/>\n  strcpy(server_addr.sun_path, \"server_socket\");  <\/p>\n<p>  \/* bind with the local file *\/<br \/>\n  bind(server_sockfd, (struct sockaddr *)&amp;server_addr, sizeof(server_addr));  <\/p>\n<p>  \/* listen *\/<br \/>\n  listen(server_sockfd, 5);  <\/p>\n<p>  char ch;<br \/>\n  int client_sockfd;<br \/>\n  struct sockaddr_un client_addr;<br \/>\n  socklen_t len = sizeof(client_addr);<br \/>\n  while(1)<br \/>\n  {<br \/>\n    printf(\"server waiting:\\n\");  <\/p>\n<p>    \/* accept a connection *\/<br \/>\n    client_sockfd = accept(server_sockfd, (struct sockaddr *)&amp;client_addr, &amp;len);  <\/p>\n<p>    \/* exchange data *\/<br \/>\n    read(client_sockfd, &amp;ch, 1);<br \/>\n    printf(\"get char from client: %c\\n\", ch);<br \/>\n    ++ch;<br \/>\n    write(client_sockfd, &amp;ch, 1);  <\/p>\n<p>    \/* close the socket *\/<br \/>\n    close(client_sockfd);<br \/>\n  }  <\/p>\n<p>  return 0;<br \/>\n}<br \/>\n\u5982\u679c\u6211\u4eec\u9996\u5148\u8fd0\u884ctcp_client\uff0c\u4f1a\u63d0\u793a\u6ca1\u6709\u8fd9\u4e2a\u6587\u4ef6\uff0c\u56e0\u4e3a\u6211\u4eec\u662f\u4ee5AF_UNIX\u65b9\u5f0f\u8fdb\u884c\u901a\u4fe1\u7684\uff0c\u8fd9\u79cd\u65b9\u5f0f\u662f\u901a\u8fc7\u6587\u4ef6\u6765\u5c06\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u8fde\u63a5\u8d77\u6765\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u5e94\u8be5\u5148\u8fd0\u884ctcp_server\uff0c\u521b\u5efa\u8fd9\u4e2a\u6587\u4ef6\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u6587\u4ef6\u4f1a\u521b\u5efa\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u5e76\u4e14\u6587\u4ef6\u5c5e\u6027\u4e2d\u7b2c\u4e00\u4e2as\u8868\u793a\u5b83\u662f\u4e00\u4e2asocket\u6587\u4ef6\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u8be6\u7ec6\u8bb2\u89e3\uff1a<\/p>\n<p><strong>1.<\/strong>\u6211\u4eec\u8c03\u7528socket\u51fd\u6570\u521b\u5efa\u4e00\u4e2asocket\uff1a<\/p>\n<p><strong>int socket(int domain, int type, int protocol)<\/strong><\/p>\n<p><strong>domain\uff1a<\/strong>\u6307\u5b9asocket\u6240\u5c5e\u7684\u57df\uff0c\u5e38\u7528\u7684\u662fAF_UNIX\u6216AF_INET<\/p>\n<p>AF_UNIX\u8868\u793a\u4ee5\u6587\u4ef6\u65b9\u5f0f\u521b\u5efasocket\uff0cAF_INET\u8868\u793a\u4ee5\u7aef\u53e3\u65b9\u5f0f\u521b\u5efasocket\uff08\u6211\u4eec\u4f1a\u5728\u540e\u9762\u8be6\u7ec6\u8bb2\u89e3AF_INET\uff09<\/p>\n<p><strong>type\uff1a<\/strong>\u6307\u5b9asocket\u7684\u7c7b\u578b\uff0c\u53ef\u4ee5\u662fSOCK_STREAM\u6216SOCK_DGRAM<\/p>\n<p><strong>SOCK_STREAM<\/strong>\u8868\u793a\u521b\u5efa\u4e00\u4e2a\u6709\u5e8f\u7684\uff0c\u53ef\u9760\u7684\uff0c\u9762\u5411\u8fde\u63a5\u7684socket\uff0c\u56e0\u6b64\u5982\u679c\u6211\u4eec\u8981\u4f7f\u7528<strong>TCP<\/strong>\uff0c\u5c31\u5e94\u8be5\u6307\u5b9a\u4e3aSOCK_STREAM<\/p>\n<p><strong>SOCK_DGRAM<\/strong>\u8868\u793a\u521b\u5efa\u4e00\u4e2a\u4e0d\u53ef\u9760\u7684\uff0c\u65e0\u8fde\u63a5\u7684socket\uff0c\u56e0\u6b64\u5982\u679c\u6211\u4eec\u8981\u4f7f\u7528<strong>UDP<\/strong>\uff0c\u5c31\u5e94\u8be5\u6307\u5b9a\u4e3aSOCK_DGRAM<\/p>\n<p><strong>protocol\uff1a<\/strong>\u6307\u5b9asocket\u7684\u534f\u8bae\u7c7b\u578b\uff0c\u6211\u4eec\u4e00\u822c\u6307\u5b9a\u4e3a0\u8868\u793a\u7531\u7b2c\u4e00\u7b2c\u4e8c\u4e24\u4e2a\u53c2\u6570\u81ea\u52a8\u9009\u62e9\u3002<\/p>\n<p><strong>socket()\u51fd\u6570\u8fd4\u56de\u65b0\u521b\u5efa\u7684socket\uff0c\u51fa\u9519\u5219\u8fd4\u56de-1<\/strong><\/p>\n<p><strong>2.<\/strong>\u5730\u5740\u683c\u5f0f\uff1a<\/p>\n<p><strong>\u5e38\u7528\u7684\u6709\u4e24\u79cdsocket\u57df\uff1aAF_UNIX\u6216AF_INET\uff0c\u56e0\u6b64\u5c31\u6709\u4e24\u79cd\u5730\u5740\u683c\u5f0f\uff1asockaddr_un\u548csockaddr_in\uff0c\u5206\u522b\u5b9a\u4e49\u5982\u4e0b\uff1a<\/strong><\/p>\n<p> struct sockaddr_un<br \/>\n{<br \/>\n  sa_family_t sun_family;  \/* AF_UNIX *\/<br \/>\n  char sun_path[];         \/* pathname *\/<br \/>\n}  <\/p>\n<p>struct sockaddr_in<br \/>\n{<br \/>\n  short int sin_family;          \/* AF_INET *\/<br \/>\n  unsigned short int sin_port;   \/* port number *\/<br \/>\n  struct in_addr sin_addr;       \/* internet address *\/<br \/>\n}<br \/>\n\/\/\u5176\u4e2din_addr\u6b63\u662f\u7528\u6765\u63cf\u8ff0\u4e00\u4e2aip\u5730\u5740\u7684\uff1a<br \/>\nstruct in_addr<br \/>\n{<br \/>\n  unsigned long int s_addr;<br \/>\n}    <\/p>\n<p>\u4ece\u4e0a\u9762\u7684\u5b9a\u4e49\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c<strong>sun_path\u5b58\u653esocket\u7684\u672c\u5730\u6587\u4ef6\u540d\uff0csin_addr\u5b58\u653esocket\u7684ip\u5730\u5740\uff0csin_port\u5b58\u653esocket\u7684\u7aef\u53e3\u53f7<\/strong>\u3002<\/p>\n<p><strong>3.<\/strong>\u521b\u5efa\u5b8c\u4e00\u4e2asocket\u540e\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528bind\u5c06\u5176\u7ed1\u5b9a\uff1a<\/p>\n<p><strong>int bind(int socket, const struct sockaddr * address, size_t address_len)<\/strong><\/p>\n<p>\u5982\u679c\u6211\u4eec\u4f7f\u7528AF_UNIX\u6765\u521b\u5efasocket\uff0c\u76f8\u5e94\u7684\u5730\u5740\u683c\u5f0f\u662fsockaddr_un\uff0c\u800c\u5982\u679c\u6211\u4eec\u4f7f\u7528AF_INET\u6765\u521b\u5efasocket\uff0c\u76f8\u5e94\u7684\u5730\u5740\u683c\u5f0f\u662fsockaddr_in\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5c06\u5176\u5f3a\u5236\u8f6c\u6362\u4e3asockaddr\u8fd9\u4e00\u901a\u7528\u7684\u5730\u5740\u683c\u5f0f\u7c7b\u578b\uff0c\u800csockaddr_un\u4e2d\u7684sun_family\u548csockaddr_in\u4e2d\u7684sin_family\u5206\u522b\u8bf4\u660e\u4e86\u5b83\u7684\u5730\u5740\u683c\u5f0f\u7c7b\u578b\uff0c\u56e0\u6b64bind()\u51fd\u6570\u5c31\u77e5\u9053\u5b83\u7684\u771f\u5b9e\u7684\u5730\u5740\u683c\u5f0f\u3002\u7b2c\u4e09\u4e2a\u53c2\u6570address_len\u5219\u6307\u660e\u4e86\u771f\u5b9e\u7684\u5730\u5740\u683c\u5f0f\u7684\u957f\u5ea6\u3002<\/p>\n<p><strong>bind()\u51fd\u6570\u6b63\u786e\u8fd4\u56de0\uff0c\u51fa\u9519\u8fd4\u56de-1<\/strong><\/p>\n<p><strong>4.<\/strong>\u63a5\u4e0b\u6765\u6211\u4eec\u9700\u8981\u5f00\u59cb\u76d1\u542c\u4e86\uff1a<\/p>\n<p><strong>int listen(int socket, int backlog)<\/strong><\/p>\n<p>backlog\uff1a\u7b49\u5f85\u8fde\u63a5\u7684\u6700\u5927\u4e2a\u6570\uff0c\u5982\u679c\u8d85\u8fc7\u4e86\u8fd9\u4e2a\u6570\u503c\uff0c\u5219\u540e\u7eed\u7684\u8bf7\u6c42\u8fde\u63a5\u5c06\u88ab\u62d2\u7edd<\/p>\n<p><strong>listen()\u51fd\u6570\u6b63\u786e\u8fd4\u56de0\uff0c\u51fa\u9519\u8fd4\u56de-1<\/strong><\/p>\n<p><strong>5.<\/strong>\u63a5\u53d7\u8fde\u63a5\uff1a<\/p>\n<p><strong>int accept(int socket, struct sockaddr * address, size_t * address_len)<\/strong><\/p>\n<p>\u540c\u6837\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e5f\u662f\u4e00\u4e2a\u901a\u7528\u5730\u5740\u683c\u5f0f\u7c7b\u578b\uff0c\u8fd9\u610f\u5473\u7740\u6211\u4eec\u9700\u8981\u8fdb\u884c\u5f3a\u5236\u7c7b\u578b\u8f6c\u5316<\/p>\n<p><strong>\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0caddress\u662f\u4e00\u4e2a\u4f20\u51fa\u53c2\u6570\uff0c\u5b83\u4fdd\u5b58\u7740\u63a5\u53d7\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\u7684\u5730\u5740\uff0c\u5982\u679c\u6211\u4eec\u4e0d\u9700\u8981\uff0c\u5c06address\u7f6e\u4e3aNULL\u5373\u53ef\u3002<\/strong><\/p>\n<p>address_len\uff1a\u6211\u4eec\u671f\u671b\u7684\u5730\u5740\u7ed3\u6784\u7684\u957f\u5ea6\uff0c\u6ce8\u610f\uff0c\u8fd9\u662f\u4e00\u4e2a\u4f20\u5165\u548c\u4f20\u51fa\u53c2\u6570\uff0c\u4f20\u5165\u65f6\u6307\u5b9a\u6211\u4eec\u671f\u671b\u7684\u5730\u5740\u7ed3\u6784\u7684\u957f\u5ea6\uff0c\u5982\u679c\u591a\u4e8e\u8fd9\u4e2a\u503c\uff0c\u5219\u4f1a\u88ab\u622a\u65ad\uff0c\u800c\u5f53accept()\u51fd\u6570\u8fd4\u56de\u65f6\uff0caddress_len\u4f1a\u88ab\u8bbe\u7f6e\u4e3a\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u5730\u5740\u7ed3\u6784\u7684\u5b9e\u9645\u957f\u5ea6\u3002<\/p>\n<p>\u53e6\u5916\u5982\u679c\u6ca1\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u65f6\uff0caccept()\u51fd\u6570\u4f1a\u963b\u585e<\/p>\n<p><strong>accept()\u51fd\u6570\u6210\u529f\u65f6\u8fd4\u56de\u65b0\u521b\u5efa\u7684socket\u63cf\u8ff0\u7b26\uff0c\u51fa\u9519\u65f6\u8fd4\u56de-1<\/strong><\/p>\n<p><strong>6.<\/strong>\u5ba2\u6237\u7aef\u901a\u8fc7connect()\u51fd\u6570\u4e0e\u670d\u52a1\u5668\u8fde\u63a5\uff1a<\/p>\n<p><strong>int connect(int socket, const struct sockaddr * address, size_t address_len)<\/strong><\/p>\n<p>\u5bf9\u4e8e\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff0c\u6211\u4eec\u540c\u6837\u9700\u8981\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362<\/p>\n<p>address_len\u6307\u660e\u4e86\u5730\u5740\u7ed3\u6784\u7684\u957f\u5ea6<\/p>\n<p><strong>connect()\u51fd\u6570\u6210\u529f\u65f6\u8fd4\u56de0\uff0c\u51fa\u9519\u65f6\u8fd4\u56de-1<\/strong><\/p>\n<p><strong>7.<\/strong><strong>\u53cc\u65b9\u90fd\u5efa\u7acb\u8fde\u63a5\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u5e38\u89c4\u7684read\/write\u51fd\u6570\u6765\u4f20\u9012\u6570\u636e\u4e86<\/strong><\/p>\n<p><strong>8.<\/strong>\u901a\u4fe1\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u5173\u95edsocket\uff1a<\/p>\n<p><strong>int close(int fd)<\/strong><\/p>\n<p>close\u662f\u4e00\u4e2a\u901a\u7528\u51fd\u6570\uff08\u548cread\uff0cwrite\u4e00\u6837\uff09\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u8fd8\u53ef\u4ee5\u5173\u95edsocket\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/blog.csdn.net\/u012662731\/article\/details\/537478 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2260","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/2260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2260"}],"version-history":[{"count":7,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/2260\/revisions"}],"predecessor-version":[{"id":2267,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/2260\/revisions\/2267"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2260"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}