{"id":52833,"date":"2019-11-17T00:00:00","date_gmt":"2019-11-16T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/polnofunktsionalnyj-i-o-reaktor-na-golom-si"},"modified":"2020-02-18T14:00:38","modified_gmt":"2020-02-18T11:00:38","slug":"polnofunktsionalnyj-i-o-reaktor-na-golom-si","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/polnofunktsionalnyj-i-o-reaktor-na-golom-si","title":{"rendered":"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438\" src=\"\/wp-content\/uploads\/2019\/11\/f28c2dd8c44e8f1961fcd81bef98bdd1.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h1 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Reactor_pattern\">I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440<\/a><\/noindex> (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Event_loop\">\u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/a><\/noindex>) \u2014 \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445:<\/p>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/nodejs.org\/en\/\">Node.js<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.torproject.org\/\">Tor<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/www.transmissionbt.com\/\">Transmission<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/www.chromium.org\/Home\">Chromium<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/memcached.org\/\">Memcached<\/a><\/noindex><\/li>\n<li>&#8230;<\/li>\n<\/ul>\n<p><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u043d\u043e\u0433\u043e\u0442\u043d\u0443\u044e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u043c\u0438\u043d.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h1 id=\"predislovie\">\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h1>\n<p><\/p>\n<ul>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043c\u043e\u0447\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u043e\u0441\u043e\u0437\u043d\u0430\u0442\u044c \u0440\u0438\u0441\u043a\u0438 \u043f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<\/li>\n<li>\u0414\u043b\u044f \u0443\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/C_%28programming_language%29\">\u044f\u0437\u044b\u043a\u0430 \u0421\u0438<\/a><\/noindex> \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/li>\n<li>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e (<strong>\u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e: \u0434\u043b\u0438\u043d\u043d\u044b\u0439 PDF<\/strong>) <noindex><a rel=\"nofollow\" href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg14\/www\/docs\/n1570.pdf\">\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 C11<\/a><\/noindex> \u0434\u043b\u044f Linux \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/Hippolot\/reactor-c\">GitHub<\/a><\/noindex>.<\/li>\n<\/ul>\n<p><\/p>\n<h1 id=\"zachem-eto-nuzhno\">\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?<\/h1>\n<p><\/p>\n<p>\u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c \u0441\u0442\u0430\u043b\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u0431\u044b\u043b\u043e \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043d\u043e \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430: \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0435 I\/O \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u041e\u0421 \u0438 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0435 I\/O \u0432 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u0435\u0449\u0451 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 &#171;\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c&#187; (<noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/epoll.7.html\">epoll<\/a><\/noindex>\/<noindex><a rel=\"nofollow\" href=\"https:\/\/man.openbsd.org\/kqueue.2\">kqueue<\/a><\/noindex>\/<noindex><a rel=\"nofollow\" href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/fileio\/i-o-completion-ports\">IOCP<\/a><\/noindex>\/etc).<\/p>\n<p><\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u041e\u0421 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0415\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0445\u0430\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c: \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Context_switch\">\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/a><\/noindex> \u0438 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/System_call\">\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/a><\/noindex>. \u041e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u0440\u043e\u0433\u0438\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0443 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0439 \u041e\u0417\u0423 \u043f\u0440\u0438 \u0432\u043d\u0443\u0448\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p><\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Thread_pool\">\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/a><\/noindex> (thread pool), \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c \u043f\u0440\u0438\u0432\u043d\u043e\u0441\u0438\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443: \u0435\u0441\u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f, \u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p><\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Notification_system\">\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445<\/a><\/noindex> (\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440), \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u041e\u0421. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0432\u0438\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f\u0445 (\u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u0445) \u043e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u043a I\/O \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c, \u043d\u0435\u0436\u0435\u043b\u0438 \u043d\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Input\/output_completion_port\">\u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f\u0445 \u043e\u0431 \u0438\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438<\/a><\/noindex>. \u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u043e\u0439:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438\" src=\"\/wp-content\/uploads\/2019\/11\/98c9205dec5e06e8697bb71e3c0549b8.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<p><\/p>\n<ul>\n<li>\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435 I\/O \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <strong>\u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442<\/strong> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u043e\u0442\u043e\u043a <strong>\u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440<\/strong>, \u043f\u043e\u043a\u0430 \u041e\u0421 \u0434\u043e\u043b\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/IP_fragmentation\">\u0434\u0435\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442<\/a><\/noindex> \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Network_packet\">IP \u043f\u0430\u043a\u0435\u0442\u044b<\/a><\/noindex> \u0432 \u043f\u043e\u0442\u043e\u043a \u0431\u0430\u0439\u0442 (<noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Transmission_Control_Protocol\">TCP<\/a><\/noindex>, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445) \u0438\u043b\u0438 \u043d\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0441\u0442\u0430 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0431\u0443\u0444\u0435\u0440\u0430\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Transmission_Control_Protocol\">NIC<\/a><\/noindex> (\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445).<\/li>\n<li>\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 <strong>\u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<\/strong> \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u041e\u0421 <strong>\u0443\u0436\u0435<\/strong> \u0434\u0435\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0430 IP \u043f\u0430\u043a\u0435\u0442\u044b (TCP, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445) \u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0441\u0442\u0430 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0431\u0443\u0444\u0435\u0440\u0430\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 <strong>\u0443\u0436\u0435<\/strong> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e (\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445).<\/li>\n<\/ul>\n<p><\/p>\n<p>\u041f\u043e\u0434\u0432\u043e\u0434\u044f \u0438\u0442\u043e\u0433, \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 \u041e\u0421 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e I\/O \u2014 \u043f\u0443\u0441\u0442\u0430\u044f \u0442\u0440\u0430\u0442\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u0438, \u0432\u0435\u0434\u044c \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0435 \u0437\u0430\u043d\u044f\u0442\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 (\u043e\u0442\u0441\u044e\u0434\u0430 \u0431\u0435\u0440\u0451\u0442 \u0441\u0432\u043e\u0438 \u043a\u043e\u0440\u043d\u0438 \u0442\u0435\u0440\u043c\u0438\u043d <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Interrupt#Software_interrupts\">&#171;\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435&#187;<\/a><\/noindex>). \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0426\u041f\u0423 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u043d\u0435\u0435.<\/p>\n<p><\/p>\n<h1 id=\"model-io-reaktora\">\u041c\u043e\u0434\u0435\u043b\u044c I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430<\/h1>\n<p><\/p>\n<p>I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c. \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043f\u0438\u0441\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u043e\u0439:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438\" src=\"\/wp-content\/uploads\/2019\/11\/fe32cb623aa195f72c6a19d83bdd0521.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<ul>\n<li>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u2014 \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0441\u043e\u043a\u0435\u0442 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0443\u044e I\/O \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/li>\n<li>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0430\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0443\u044e I\/O \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/li>\n<\/ul>\n<p><\/p>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u0435\u043d, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0442 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 1 \u043f\u043e\u0442\u043e\u043a: 1 \u0440\u0435\u0430\u043a\u0442\u043e\u0440, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u0432\u0441\u0435 \u044f\u0434\u0440\u0430 \u0426\u041f\u0423.<\/p>\n<p><\/p>\n<h1 id=\"realizaciya\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h1>\n<p><\/p>\n<p>\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u0444\u0430\u0439\u043b <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/Hippolot\/reactor-c\/blob\/master\/reactor.h\"><code>reactor.h<\/code><\/a><\/noindex>, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u2014 \u0432 <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/Hippolot\/reactor-c\/blob\/master\/reactor.c\"><code>reactor.c<\/code><\/a><\/noindex>. <code>reactor.h<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439:<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432 reactor.h<\/b><\/p>\n<pre><code class=\"cpp\">typedef struct reactor Reactor;\n\n\/*\n * \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438\n * \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430.\n *\/\ntypedef void (*Callback)(void *arg, int fd, uint32_t events);\n\n\/*\n * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 `NULL` \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0435-`NULL` \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 `Reactor` \u0432\n * \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.\n *\/\nReactor *reactor_new(void);\n\n\/*\n * \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440, \u0432\u0441\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u043a\u0435\u0442\u044b \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442\n * \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0441\u0430\u043c I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440.\n *\n * \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 -1 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, 0 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0445\u0430.\n *\/\nint reactor_destroy(Reactor *reactor);\n\nint reactor_register(const Reactor *reactor, int fd, uint32_t interest,\n                     Callback callback, void *callback_arg);\nint reactor_deregister(const Reactor *reactor, int fd);\nint reactor_reregister(const Reactor *reactor, int fd, uint32_t interest,\n                       Callback callback, void *callback_arg);\n\n\/*\n * \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441 \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u043e\u043c `timeout`.\n *\n * \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0434\u0443 \u0435\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0448\u043b\u043e\n * \u0438\u043b\u0438\/\u0438 \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043a\u0435\u0442\u043e\u0432.\n *\/\nint reactor_run(const Reactor *reactor, time_t timeout);<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/File_descriptor\">\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430<\/a><\/noindex> \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/epoll.7.html\">epoll<\/a><\/noindex> \u0438 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Hash_table\">\u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/a><\/noindex> <noindex><a rel=\"nofollow\" href=\"https:\/\/developer.gnome.org\/glib\/stable\/glib-Hash-Tables.html\"><code>GHashTable<\/code><\/a><\/noindex>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e\u043a\u0435\u0442 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441 <code>CallbackData<\/code> (\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f \u043d\u0435\u0433\u043e).<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c Reactor \u0438 CallbackData<\/b><\/p>\n<pre><code class=\"cpp\">struct reactor {\n    int epoll_fd;\n    GHashTable *table; \/\/ (int, CallbackData)\n};\n\ntypedef struct {\n    Callback callback;\n    void *arg;\n} CallbackData;<\/code><\/pre>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0441 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.cppreference.com\/w\/c\/language\/type#Incomplete_types\">\u043d\u0435\u043f\u043e\u043b\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c<\/a><\/noindex> \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e. \u0412 <code>reactor.h<\/code> \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>reactor<\/code>, \u0430 \u0432 <code>reactor.c<\/code> \u0435\u0451 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u044f\u0432\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0451 \u043f\u043e\u043b\u044f. \u042d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Information_hiding\">\u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/a><\/noindex>, \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0432 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 \u0421\u0438.<\/p>\n<p><\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 <code>reactor_register<\/code>, <code>reactor_deregister<\/code> \u0438 <code>reactor_reregister<\/code> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u0441\u043e\u043a\u0435\u0442\u043e\u0432 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0435 \u0438 \u0432 \u0445\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438<\/b><\/p>\n<pre><code class=\"cpp\">#define REACTOR_CTL(reactor, op, fd, interest)                                 \n    if (epoll_ctl(reactor-&gt;epoll_fd, op, fd,                                   \n                  &amp;(struct epoll_event){.events = interest,                    \n                                        .data = {.fd = fd}}) == -1) {          \n        perror(\"epoll_ctl\");                                                   \n        return -1;                                                             \n    }\n\nint reactor_register(const Reactor *reactor, int fd, uint32_t interest,\n                     Callback callback, void *callback_arg) {\n    REACTOR_CTL(reactor, EPOLL_CTL_ADD, fd, interest)\n    g_hash_table_insert(reactor-&gt;table, int_in_heap(fd),\n                        callback_data_new(callback, callback_arg));\n    return 0;\n}\n\nint reactor_deregister(const Reactor *reactor, int fd) {\n    REACTOR_CTL(reactor, EPOLL_CTL_DEL, fd, 0)\n    g_hash_table_remove(reactor-&gt;table, &amp;fd);\n    return 0;\n}\n\nint reactor_reregister(const Reactor *reactor, int fd, uint32_t interest,\n                       Callback callback, void *callback_arg) {\n    REACTOR_CTL(reactor, EPOLL_CTL_MOD, fd, interest)\n    g_hash_table_insert(reactor-&gt;table, int_in_heap(fd),\n                        callback_data_new(callback, callback_arg));\n    return 0;\n}<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u043c <code>fd<\/code>, \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 <code>fd<\/code>, <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Mask_(computing)\">\u0431\u0438\u0442\u043e\u0432\u0443\u044e \u043c\u0430\u0441\u043a\u0443<\/a><\/noindex> \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 <code>void<\/code>.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e reactor_run()<\/b><\/p>\n<pre><code class=\"cpp\">int reactor_run(const Reactor *reactor, time_t timeout) {\n    int result;\n    struct epoll_event *events;\n    if ((events = calloc(MAX_EVENTS, sizeof(*events))) == NULL)\n        abort();\n\n    time_t start = time(NULL);\n\n    while (true) {\n        time_t passed = time(NULL) - start;\n        int nfds =\n            epoll_wait(reactor-&gt;epoll_fd, events, MAX_EVENTS, timeout - passed);\n\n        switch (nfds) {\n        \/\/ \u041e\u0448\u0438\u0431\u043a\u0430\n        case -1:\n            perror(\"epoll_wait\");\n            result = -1;\n            goto cleanup;\n        \/\/ \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u0448\u043b\u043e\n        case 0:\n            result = 0;\n            goto cleanup;\n        \/\/ \u0423\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\n        default:\n            \/\/ \u0412\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439\n            for (int i = 0; i &lt; nfds; i++) {\n                int fd = events[i].data.fd;\n\n                CallbackData *callback =\n                    g_hash_table_lookup(reactor-&gt;table, &amp;fd);\n                callback-&gt;callback(callback-&gt;arg, fd, events[i].events);\n            }\n        }\n    }\n\ncleanup:\n    free(events);\n    return result;\n}<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u043e\u0434\u0432\u043e\u0434\u044f \u0438\u0442\u043e\u0433, \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438\" src=\"\/wp-content\/uploads\/2019\/11\/2d330bd82854acfb751f10b833bdccb5.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h1 id=\"odnopotochnyy-server\">\u041e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440<\/h1>\n<p><\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041a\u0440\u0430\u0442\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043b\u0443 HTTP<\/b><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/HTML\">HTTP<\/a><\/noindex> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Application_layer\">\u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f<\/a><\/noindex>, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c.<\/p>\n<p><\/p>\n<p>HTTP \u043c\u043e\u0436\u043d\u043e \u0441 \u043b\u0451\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0440\u0445 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Transport_layer\">\u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0433\u043e<\/a><\/noindex> \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Transmission_Control_Protocol\">TCP<\/a><\/noindex>, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e <noindex><a rel=\"nofollow\" href=\"https:\/\/tools.ietf.org\/html\/rfc2616\">\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439<\/a><\/noindex>.<\/p>\n<p><\/p>\n<h3 id=\"format-zaprosa\">\u0424\u043e\u0440\u043c\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h3>\n<p><\/p>\n<pre><code class=\"plaintext\">&lt;\u041a\u041e\u041c\u0410\u041d\u0414\u0410&gt; &lt;URI&gt; &lt;\u0412\u0415\u0420\u0421\u0418\u042f HTTP&gt;CRLF\n&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a 1&gt;CRLF\n&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a 2&gt;CRLF\n&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a N&gt;CRLF CRLF\n&lt;\u0414\u0410\u041d\u041d\u042b\u0415&gt;<\/code><\/pre>\n<p><\/p>\n<ul>\n<li><code>CRLF<\/code> \u2014 \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432: <code>r<\/code> \u0438 <code>n<\/code>, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<\/li>\n<li><code>&lt;\u041a\u041e\u041c\u0410\u041d\u0414\u0410&gt;<\/code> \u2014 \u043e\u0434\u043d\u043e \u0438\u0437 <code>CONNECT<\/code>, <code>DELETE<\/code>, <code>GET<\/code>, <code>HEAD<\/code>, <code>OPTIONS<\/code>, <code>PATCH<\/code>, <code>POST<\/code>, <code>PUT<\/code>, <code>TRACE<\/code>. \u0411\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430\u0448\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>GET<\/code>, \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0443\u044e &#171;\u041e\u0442\u043f\u0440\u0430\u0432\u044c \u043c\u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430&#187;.<\/li>\n<li><code>&lt;URI&gt;<\/code> \u2014 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Uniform_Resource_Identifier\">y\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u0430<\/a><\/noindex>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 URI = <code>\/index.html<\/code>, \u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430.<\/li>\n<li><code>&lt;\u0412\u0415\u0420\u0421\u0418\u042f HTTP&gt;<\/code> \u2014 \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 HTTP \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>HTTP\/X.Y<\/code>. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u2014 <code>HTTP\/1.1<\/code>.<\/li>\n<li><code>&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a N&gt;<\/code> \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0430 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>&lt;\u041a\u041b\u042e\u0427&gt;: &lt;\u0417\u041d\u0410\u0427\u0415\u041d\u0418\u0415&gt;<\/code>, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/li>\n<li><code>&lt;\u0414\u0410\u041d\u041d\u042b\u0415&gt;<\/code> \u2014 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0427\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e <noindex><a rel=\"nofollow\" href=\"https:\/\/json.org\/\">JSON<\/a><\/noindex> \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442.<\/li>\n<\/ul>\n<p><\/p>\n<h3 id=\"format-otveta\">\u0424\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430<\/h3>\n<p><\/p>\n<pre><code class=\"plaintext\">&lt;\u0412\u0415\u0420\u0421\u0418\u042f HTTP&gt; &lt;\u041a\u041e\u0414 \u0421\u0422\u0410\u0422\u0423\u0421\u0410&gt; &lt;\u041e\u041f\u0418\u0421\u0410\u041d\u0418\u0415 \u0421\u0422\u0410\u0422\u0423\u0421\u0410&gt;CRLF\n&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a 1&gt;CRLF\n&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a 2&gt;CRLF\n&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a N&gt;CRLF CRLF\n&lt;\u0414\u0410\u041d\u041d\u042b\u0415&gt;<\/code><\/pre>\n<p><\/p>\n<ul>\n<li><code>&lt;\u041a\u041e\u0414 \u0421\u0422\u0410\u0422\u0423\u0421\u0410&gt;<\/code> \u2014 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0441\u043e\u0431\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 200 (\u0443\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f).<\/li>\n<li><code>&lt;\u041e\u041f\u0418\u0421\u0410\u041d\u0418\u0415 \u0421\u0422\u0410\u0422\u0423\u0421\u0410&gt;<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430. \u0414\u043b\u044f \u043a\u043e\u0434\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 200 \u2014 \u044d\u0442\u043e <code>OK<\/code>.<\/li>\n<li><code>&lt;\u0417\u0410\u0413\u041e\u041b\u041e\u0412\u041e\u041a N&gt;<\/code> \u2014 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0442\u043e\u0433\u043e \u0436\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u0447\u0442\u043e \u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 <code>Content-Length<\/code> (\u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430) \u0438 <code>Content-Type: text\/html<\/code> (\u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445).<\/li>\n<li><code>&lt;\u0414\u0410\u041d\u041d\u042b\u0415&gt;<\/code> \u2014 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043f\u0443\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0432 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/HTML\">HTML<\/a><\/noindex>.<\/li>\n<\/ul>\n<p><\/p>\n<p>\u0424\u0430\u0439\u043b <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/Hippolot\/reactor-c\/blob\/master\/http_server.c\"><code>http_server.c<\/code><\/a><\/noindex> (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440) \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0444\u0430\u0439\u043b <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/Hippolot\/reactor-c\/blob\/master\/common.h\"><code>common.h<\/code><\/a><\/noindex>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 common.h<\/b><\/p>\n<pre><code class=\"cpp\">\/*\n * \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u043a\u0435\u0442 \u0431\u0443\u0434\u0435\u0442\n * \u0433\u043e\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435.\n *\/\nstatic void on_accept(void *arg, int fd, uint32_t events);\n\n\/*\n * \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u043a\u0435\u0442 \u0431\u0443\u0434\u0435\u0442\n * \u0433\u043e\u0442\u043e\u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c HTTP \u043e\u0442\u0432\u0435\u0442.\n *\/\nstatic void on_send(void *arg, int fd, uint32_t events);\n\n\/*\n * \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u043a\u0435\u0442 \u0431\u0443\u0434\u0435\u0442\n * \u0433\u043e\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0447\u0430\u0441\u0442\u044c HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\n *\/\nstatic void on_recv(void *arg, int fd, uint32_t events);\n\n\/*\n * \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c.\n *\/\nstatic void set_nonblocking(int fd);\n\n\/*\n * \u041f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 stderr \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\n * \u043a\u043e\u0434\u043e\u043c `EXIT_FAILURE`.\n *\/\nstatic noreturn void fail(const char *format, ...);\n\n\/*\n * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441\u043e\u043a\u0435\u0442\u0430, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435\n * TCP \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.\n *\/\nstatic int new_server(bool reuse_port);<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 <code>SAFE_CALL()<\/code> \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>fail()<\/code>. \u041c\u0430\u043a\u0440\u043e\u0441 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0438 \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043d\u0438\u043b\u043e\u0441\u044c, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>fail()<\/code>:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">#define SAFE_CALL(call, error)                                                 \n    do {                                                                       \n        if ((call) == error) {                                                   \n            fail(\"%s\", #call);                                                 \n        }                                                                      \n    } while (false)<\/code><\/pre>\n<p><\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>fail()<\/code> \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b (\u043a\u0430\u043a <noindex><a rel=\"nofollow\" href=\"https:\/\/en.cppreference.com\/w\/c\/io\/fprintf\"><code>printf()<\/code><\/a><\/noindex>) \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 \u043a\u043e\u0434\u043e\u043c <code>EXIT_FAILURE<\/code>:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">static noreturn void fail(const char *format, ...) {\n    va_list args;\n    va_start(args, format);\n    vfprintf(stderr, format, args);\n    va_end(args);\n    fprintf(stderr, \": %sn\", strerror(errno));\n    exit(EXIT_FAILURE);\n}<\/code><\/pre>\n<p><\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>new_server()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 &#171;\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e&#187; \u0441\u043e\u043a\u0435\u0442\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/socket.2.html\"><code>socket()<\/code><\/a><\/noindex>, <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/bind.2.html\"><code>bind()<\/code><\/a><\/noindex> \u0438 <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/listen.2.html\"><code>listen()<\/code><\/a><\/noindex> \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e new_server()<\/b><\/p>\n<pre><code class=\"cpp\">static int new_server(bool reuse_port) {\n    int fd;\n    SAFE_CALL((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP)),\n              -1);\n\n    if (reuse_port) {\n        SAFE_CALL(\n            setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &amp;(int){1}, sizeof(int)),\n            -1);\n    }\n\n    struct sockaddr_in addr = {.sin_family = AF_INET,\n                               .sin_port = htons(SERVER_PORT),\n                               .sin_addr = {.s_addr = inet_addr(SERVER_IPV4)},\n                               .sin_zero = {0}};\n\n    SAFE_CALL(bind(fd, (struct sockaddr *)&amp;addr, sizeof(addr)), -1);\n    SAFE_CALL(listen(fd, SERVER_BACKLOG), -1);\n    return fd;\n}<\/code><\/pre>\n<p><\/p>\n<ul>\n<li>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u043e\u043a\u0435\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043b\u0430\u0433\u0430 <code>SOCK_NONBLOCK<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>on_accept()<\/code> (\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435) \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>accept()<\/code> \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430.<\/li>\n<li>\u0415\u0441\u043b\u0438 <code>reuse_port<\/code> \u0440\u0430\u0432\u0435\u043d <code>true<\/code>, \u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u043a\u0435\u0442 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/socket.7.html\"><code>SO_REUSEPORT<\/code><\/a><\/noindex> \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <noindex><a rel=\"nofollow\" href=\"https:\/\/linux.die.net\/man\/2\/setsockopt\"><code>setsockopt()<\/code><\/a><\/noindex>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043f\u043e\u0440\u0442 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 (\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e &#171;\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440&#187;).<\/li>\n<\/ul>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 <code>on_accept()<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u041e\u0421 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>EPOLLIN<\/code>, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043d\u044f\u0442\u043e. <code>on_accept()<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0436\u0438\u043c \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f <code>on_recv()<\/code> \u0432 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e on_accept()<\/b><\/p>\n<pre><code class=\"cpp\">static void on_accept(void *arg, int fd, uint32_t events) {\n    int incoming_conn;\n    SAFE_CALL((incoming_conn = accept(fd, NULL, NULL)), -1);\n    set_nonblocking(incoming_conn);\n    SAFE_CALL(reactor_register(reactor, incoming_conn, EPOLLIN, on_recv,\n                               request_buffer_new()),\n              -1);\n}<\/code><\/pre>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 <code>on_recv()<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u041e\u0421 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>EPOLLIN<\/code>, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 <code>on_accept()<\/code>, \u0433\u043e\u0442\u043e\u0432\u043e \u043a \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><\/p>\n<p><code>on_recv()<\/code> \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 HTTP \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d, \u0437\u0430\u0442\u0435\u043c \u043e\u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a <code>on_send()<\/code> \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 HTTP \u043e\u0442\u0432\u0435\u0442\u0430. \u0415\u0441\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442 \u043e\u0431\u043e\u0440\u0432\u0430\u043b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0442\u043e \u0441\u043e\u043a\u0435\u0442 \u0434\u0435\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/close.2.html\"><code>close()<\/code><\/a><\/noindex>.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e on_recv()<\/b><\/p>\n<pre><code class=\"cpp\">static void on_recv(void *arg, int fd, uint32_t events) {\n    RequestBuffer *buffer = arg;\n\n    \/\/ \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u0447\u0442\u043e recv \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442 0 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443\n    ssize_t nread;\n    while ((nread = recv(fd, buffer-&gt;data + buffer-&gt;size,\n                         REQUEST_BUFFER_CAPACITY - buffer-&gt;size, 0)) &gt; 0)\n        buffer-&gt;size += nread;\n\n    \/\/ \u041a\u043b\u0438\u0435\u043d\u0442 \u043e\u0431\u043e\u0440\u0432\u0430\u043b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\n    if (nread == 0) {\n        SAFE_CALL(reactor_deregister(reactor, fd), -1);\n        SAFE_CALL(close(fd), -1);\n        request_buffer_destroy(buffer);\n        return;\n    }\n\n    \/\/ read \u0432\u0435\u0440\u043d\u0443\u043b \u043e\u0448\u0438\u0431\u043a\u0443, \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u043e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\n    \/\/ \u043f\u043e\u0442\u043e\u043a\n    if (errno != EAGAIN &amp;&amp; errno != EWOULDBLOCK) {\n        request_buffer_destroy(buffer);\n        fail(\"read\");\n    }\n\n    \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 HTTP \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\n    \/\/ \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445\n    if (request_buffer_is_complete(buffer)) {\n        request_buffer_clear(buffer);\n        SAFE_CALL(reactor_reregister(reactor, fd, EPOLLOUT, on_send, buffer),\n                  -1);\n    }\n}<\/code><\/pre>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 <code>on_send()<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u041e\u0421 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>EPOLLOUT<\/code>, \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 <code>on_recv()<\/code>, \u0433\u043e\u0442\u043e\u0432\u043e \u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 HTTP \u043e\u0442\u0432\u0435\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 HTML \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u043a\u043b\u0438\u0435\u043d\u0442\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441\u043d\u043e\u0432\u0430 \u043d\u0430 <code>on_recv()<\/code>.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e on_send()<\/b><\/p>\n<pre><code class=\"cpp\">static void on_send(void *arg, int fd, uint32_t events) {\n    const char *content = \"&lt;img \"\n                          \"src=\"https:\/\/habrastorage.org\/webt\/oh\/wl\/23\/\"\n                          \"ohwl23va3b-dioerobq_mbx4xaw.jpeg\"&gt;\";\n    char response[1024];\n    sprintf(response,\n            \"HTTP\/1.1 200 OK\" CRLF \"Content-Length: %zd\" CRLF \"Content-Type: \"\n            \"text\/html\" DOUBLE_CRLF \"%s\",\n            strlen(content), content);\n\n    SAFE_CALL(send(fd, response, strlen(response), 0), -1);\n    SAFE_CALL(reactor_reregister(reactor, fd, EPOLLIN, on_recv, arg), -1);\n}<\/code><\/pre>\n<p><\/p>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432 \u0444\u0430\u0439\u043b\u0435 <code>http_server.c<\/code>, \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>main()<\/code> \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <code>reactor_new()<\/code>, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u0441\u043e\u043a\u0435\u0442 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>reactor_run()<\/code> \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u0443 \u043c\u0438\u043d\u0443\u0442\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c http_server.c<\/b><\/p>\n<pre><code class=\"cpp\">#include \"reactor.h\"\n\nstatic Reactor *reactor;\n\n#include \"common.h\"\n\nint main(void) {\n    SAFE_CALL((reactor = reactor_new()), NULL);\n    SAFE_CALL(\n        reactor_register(reactor, new_server(false), EPOLLIN, on_accept, NULL),\n        -1);\n    SAFE_CALL(reactor_run(reactor, SERVER_TIMEOUT_MILLIS), -1);\n    SAFE_CALL(reactor_destroy(reactor), -1);\n}<\/code><\/pre>\n<p><\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e. \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c (<code>chmod a+x compile.sh &amp;&amp; .\/compile.sh<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430) \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c <noindex><a rel=\"nofollow\" href=\"http:\/\/127.0.0.1:18470\">http:\/\/127.0.0.1:18470<\/a><\/noindex> \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u0438:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438\" src=\"\/wp-content\/uploads\/2019\/11\/06a519d361f870190692d5dfd37823ed.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h1 id=\"zamer-proizvoditelnosti\">\u0417\u0430\u043c\u0435\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h1>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<\/b><\/p>\n<pre><code class=\"plaintext\">$ screenfetch\n MMMMMMMMMMMMMMMMMMMMMMMMMmds+.        OS: Mint 19.1 tessa\n MMm----::-:\/\/\/\/\/\/\/\/\/\/\/\/\/\/oymNMd+`     Kernel: x86_64 Linux 4.15.0-20-generic\n MMd      \/++                -sNMd:    Uptime: 2h 34m\n MMNso\/`  dMM    `.::-. .-::.` .hMN:   Packages: 2217\n ddddMMh  dMM   :hNMNMNhNMNMNh: `NMm   Shell: bash 4.4.20\n     NMm  dMM  .NMN\/-+MMM+-\/NMN` dMM   Resolution: 1920x1080\n     NMm  dMM  -MMm  `MMM   dMM. dMM   DE: Cinnamon 4.0.10\n     NMm  dMM  -MMm  `MMM   dMM. dMM   WM: Muffin\n     NMm  dMM  .mmd  `mmm   yMM. dMM   WM Theme: Mint-Y-Dark (Mint-Y)\n     NMm  dMM`  ..`   ...   ydm. dMM   GTK Theme: Mint-Y [GTK2\/3]\n     hMM- +MMd\/-------...-:sdds  dMM   Icon Theme: Mint-Y\n     -NMm- :hNMNNNmdddddddddy\/`  dMM   Font: Noto Sans 9\n      -dMNs-``-::::-------.``    dMM   CPU: Intel Core i7-6700 @ 8x 4GHz [52.0\u00b0C]\n       `\/dMNmy+\/:-------------:\/yMMM   GPU: NV136\n          .\/ydNMMMMMMMMMMMMMMMMMMMMM   RAM: 2544MiB \/ 7926MiB\n             .MMMMMMMMMMMMMMMMMMM<\/code><\/pre>\n<p><\/p>\n<p>\u0418\u0437\u043c\u0435\u0440\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0434\u0432\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430: \u0432 \u043e\u0434\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>.\/http_server<\/code>, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u2014 <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/wg\/wrk\">wrk<\/a><\/noindex>. \u0421\u043f\u0443\u0441\u0442\u044f \u043c\u0438\u043d\u0443\u0442\u0443 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0432\u044b\u0441\u0432\u0435\u0442\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">$ wrk -c100 -d1m -t8 http:\/\/127.0.0.1:18470 -H \"Host: 127.0.0.1:18470\" -H \"Accept-Language: en-US,en;q=0.5\" -H \"Connection: keep-alive\"\nRunning 1m test @ http:\/\/127.0.0.1:18470\n  8 threads and 100 connections\n  Thread Stats   Avg      Stdev     Max   +\/- Stdev\n    Latency   493.52us   76.70us  17.31ms   89.57%\n    Req\/Sec    24.37k     1.81k   29.34k    68.13%\n  11657769 requests in 1.00m, 1.60GB read\nRequests\/sec: 193974.70\nTransfer\/sec:     27.19MB<\/code><\/pre>\n<p><\/p>\n<p>\u041d\u0430\u0448 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043c\u043e\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 11 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443, \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438\u0437 100 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u041d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0435\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c?<\/p>\n<p><\/p>\n<h1 id=\"mnogopotochnyy-server\">\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440<\/h1>\n<p><\/p>\n<p>\u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u0432\u0441\u0435 \u044f\u0434\u0440\u0430 \u0426\u041f\u0423. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435:<\/p>\n<p>\n<b class=\"spoiler_title\">\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c http_server_multithreaded.c<\/b><\/p>\n<pre><code class=\"cpp\">#include \"reactor.h\"\n\nstatic Reactor *reactor;\n#pragma omp threadprivate(reactor)\n\n#include \"common.h\"\n\nint main(void) {\n#pragma omp parallel\n    {\n        SAFE_CALL((reactor = reactor_new()), NULL);\n        SAFE_CALL(reactor_register(reactor, new_server(true), EPOLLIN,\n                                   on_accept, NULL),\n                  -1);\n        SAFE_CALL(reactor_run(reactor, SERVER_TIMEOUT_MILLIS), -1);\n        SAFE_CALL(reactor_destroy(reactor), -1);\n    }\n}<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Thread-local_storage\">\u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c<\/a><\/noindex> \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u043e\u043c:<\/p>\n<p><\/p>\n<pre><code class=\"cpp\">static Reactor *reactor;\n#pragma omp threadprivate(reactor)<\/code><\/pre>\n<p><\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>new_server()<\/code> \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 <code>true<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u043c\u0443 \u0441\u043e\u043a\u0435\u0442\u0443 \u043e\u043f\u0446\u0438\u044e <noindex><a rel=\"nofollow\" href=\"http:\/\/man7.org\/linux\/man-pages\/man7\/socket.7.html\"><code>SO_REUSEPORT<\/code><\/a><\/noindex>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <noindex><a rel=\"nofollow\" href=\"https:\/\/stackoverflow.com\/questions\/14388706\/how-do-so-reuseaddr-and-so-reuseport-differ#14388707\">\u0442\u0443\u0442<\/a><\/noindex>.<\/p>\n<p><\/p>\n<h1 id=\"vtoroy-zahod\">\u0412\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0445\u043e\u0434<\/h1>\n<p><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437\u043c\u0435\u0440\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">$ wrk -c100 -d1m -t8 http:\/\/127.0.0.1:18470 -H \"Host: 127.0.0.1:18470\" -H \"Accept-Language: en-US,en;q=0.5\" -H \"Connection: keep-alive\"\nRunning 1m test @ http:\/\/127.0.0.1:18470\n  8 threads and 100 connections\n  Thread Stats   Avg      Stdev     Max   +\/- Stdev\n    Latency     1.14ms    2.53ms  40.73ms   89.98%\n    Req\/Sec    79.98k    18.07k  154.64k    78.65%\n  38208400 requests in 1.00m, 5.23GB read\nRequests\/sec: 635876.41\nTransfer\/sec:     89.14MB<\/code><\/pre>\n<p><\/p>\n<p>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430 1 \u043c\u0438\u043d\u0443\u0442\u0443 \u0432\u043e\u0437\u0440\u043e\u0441\u043b\u043e \u0432 ~3.28 \u0440\u0430\u0437\u0430! \u041d\u043e \u0434\u043e \u043a\u0440\u0443\u0433\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0432\u0441\u0435\u0433\u043e ~\u0434\u0432\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p><\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e <noindex><a rel=\"nofollow\" href=\"https:\/\/perf.wiki.kernel.org\/index.php\/Main_Page\">perf<\/a><\/noindex>:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">$ sudo perf stat -B -e task-clock,context-switches,cpu-migrations,page-faults,cycles,instructions,branches,branch-misses,cache-misses .\/http_server_multithreaded\n\n Performance counter stats for '.\/http_server_multithreaded':\n\n     242446,314933      task-clock (msec)         #    4,000 CPUs utilized          \n         1\u202f813\u202f074      context-switches          #    0,007 M\/sec                  \n             4\u202f689      cpu-migrations            #    0,019 K\/sec                  \n               254      page-faults               #    0,001 K\/sec                  \n   895\u202f324\u202f830\u202f170      cycles                    #    3,693 GHz                    \n   621\u202f378\u202f066\u202f808      instructions              #    0,69  insn per cycle         \n   119\u202f926\u202f709\u202f370      branches                  #  494,653 M\/sec                  \n     3\u202f227\u202f095\u202f669      branch-misses             #    2,69% of all branches        \n           808\u202f664      cache-misses                                                \n\n      60,604330670 seconds time elapsed<\/code><\/pre>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Processor_affinity\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0444\u0444\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u0426\u041f\u0423<\/a><\/noindex>, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0441 <code>-march=native<\/code>, <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Profile-guided_optimization\">PGO<\/a><\/noindex>, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0439 \u0432 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/CPU_cache\">\u043a\u0435\u0448<\/a><\/noindex>, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 <code>MAX_EVENTS<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>EPOLLET<\/code> \u043d\u0435 \u0434\u0430\u043b\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041d\u043e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439?<\/p>\n<p><\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u0440\u0438 352 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u0445:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">$ wrk -c352 -d1m -t8 http:\/\/127.0.0.1:18470 -H \"Host: 127.0.0.1:18470\" -H \"Accept-Language: en-US,en;q=0.5\" -H \"Connection: keep-alive\"\nRunning 1m test @ http:\/\/127.0.0.1:18470\n  8 threads and 352 connections\n  Thread Stats   Avg      Stdev     Max   +\/- Stdev\n    Latency     2.12ms    3.79ms  68.23ms   87.49%\n    Req\/Sec    83.78k    12.69k  169.81k    83.59%\n  40006142 requests in 1.00m, 5.48GB read\nRequests\/sec: 665789.26\nTransfer\/sec:     93.34MB<\/code><\/pre>\n<p><\/p>\n<p>\u0416\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430 1 \u043c\u0438\u043d\u0443\u0442\u0443 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438\" src=\"\/wp-content\/uploads\/2019\/11\/b40c26a4facaea38611c9b14e943a30b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0440\u044b \u0441\u043e\u0442\u0435\u043d \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0443 \u043e\u0431\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0440\u0435\u0437\u043a\u043e \u043f\u0430\u0434\u0430\u0435\u0442 (\u0443 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e). \u0421\u0432\u044f\u0437\u0430\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 TCP\/IP \u0441\u0442\u0435\u043a\u0430 Linux? \u0421\u0432\u043e\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0447\u0451\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0441\u043c\u0435\u043b\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p>\u041a\u0430\u043a <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/en\/post\/475896\/#comment_20887744\">\u043e\u0442\u043c\u0435\u0442\u0438\u043b\u0438<\/a><\/noindex> \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u0445, \u0432\u0435\u0434\u044c \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0411\u0414, \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043b\u043e\u0433\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u0441 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Transport_Layer_Security\">TLS<\/a><\/noindex> \u0438 \u0442.\u0434., \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u0433\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0439 (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439). \u0422\u0435\u0441\u0442\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e I\/O \u043f\u0440\u043e\u0430\u043a\u0442\u043e\u0440.<\/p>\n<p><\/p>\n<h1 id=\"nedostatki-io-reaktora\">\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430<\/h1>\n<p><\/p>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0435 \u043b\u0438\u0448\u0451\u043d \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e:<\/p>\n<p><\/p>\n<ul>\n<li>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u043e\u043c \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0442.\u043a. \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<\/li>\n<li>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u0432\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u043e\u0439.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a, \u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u0441\u0430\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u0440\u0443\u0434\u043d\u043e\u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u044b\u043c \u0431\u0430\u0433\u0430\u043c.<\/li>\n<\/ul>\n<p><\/p>\n<p>\u042d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u0435\u0442 <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Proactor_pattern\">I\/O \u043f\u0440\u043e\u0430\u043a\u0442\u043e\u0440<\/a><\/noindex>, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0438 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 API. \u0420\u0435\u0447\u044c \u043e \u043d\u0451\u043c \u043f\u043e\u0439\u0434\u0451\u0442 \u043f\u043e\u0437\u0436\u0435, \u0432 \u043c\u043e\u0435\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p><\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p><\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0438\u0437 \u0442\u0435\u043e\u0440\u0438\u0438 \u043f\u0440\u044f\u043c\u0438\u043a\u043e\u043c \u0432 \u0432\u044b\u0445\u043b\u043e\u043f \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440\u0430 \u043f\u043e\u0434\u043e\u0448\u043b\u043e \u043a \u043a\u043e\u043d\u0446\u0443.<\/p>\n<p><\/p>\n<p>\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0432\u0435\u0434\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u041f\u041e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0438\u0436\u0435.<\/p>\n<p><\/p>\n<p>\u0414\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447!<\/p>\n<p><\/p>\n<h1 id=\"interesnye-proekty\">\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b<\/h1>\n<p><\/p>\n<ul>\n<li>\u0421\u0438\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/libevent.org\/\">libevent<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/enki\/libev\">libev<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/libuv.org\/\">libuv<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/criticalstack\/libevhtp\">libevhtp<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/axboe\/liburing\">liburing<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.dpdk.org\/\">DPDK<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/luigirizzo\/netmap\">netmap<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.ntop.org\/products\/packet-capture\/pf_ring\/\">PF_RING<\/a><\/noindex><\/li>\n<\/ul>\n<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.rust-lang.org\/\">Rust<\/a><\/noindex>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tokio-rs\/mio\">Mio<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/tokio.rs\/\">Tokio<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/m-labs\/smoltcp\">smoltcp<\/a><\/noindex><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><\/p>\n<h1 id=\"chto-eschyo-pochitat\">\u0427\u0442\u043e \u0435\u0449\u0451 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c?<\/h1>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/linux.die.net\/man\/7\/socket\">https:\/\/linux.die.net\/man\/7\/socket<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/stackoverflow.com\/questions\/1050222\/what-is-the-difference-between-concurrency-and-parallelism\">https:\/\/stackoverflow.com\/questions\/1050222\/what-is-the-difference-between-concurrency-and-parallelism<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"http:\/\/www.kegel.com\/c10k.html\">http:\/\/www.kegel.com\/c10k.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/kernel.dk\/io_uring.pdf\">https:\/\/kernel.dk\/io_uring.pdf<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/aturon.github.io\/blog\/2016\/09\/07\/futures-design\/\">https:\/\/aturon.github.io\/blog\/2016\/09\/07\/futures-design\/<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/tokio.rs\/blog\/2019-10-scheduler\/\">https:\/\/tokio.rs\/blog\/2019-10-scheduler\/<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/www.artima.com\/articles\/io_design_patterns.html\">https:\/\/www.artima.com\/articles\/io_design_patterns.html<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/en\/post\/183832\/\">https:\/\/habr.com\/en\/post\/183832\/<\/a><\/noindex><\/li>\n<\/ul>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/475896\/\">habr.com<\/a><\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439) \u2014 \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445: Node.js Tor Transmission Chromium Memcached &#8230; \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u043d\u043e\u0433\u043e\u0442\u043d\u0443\u044e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u043c\u0438\u043d. \u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-52833","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439) \u2014 \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445: Node.js Tor Transmission Chromium Memcached ... \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u043d\u043e\u0433\u043e\u0442\u043d\u0443\u044e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u043c\u0438\u043d. \u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/polnofunktsionalnyj-i-o-reaktor-na-golom-si\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"sq_AL\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439) \u2014 \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445: Node.js Tor Transmission Chromium Memcached ... \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u043d\u043e\u0433\u043e\u0442\u043d\u0443\u044e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u043c\u0438\u043d. \u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/polnofunktsionalnyj-i-o-reaktor-na-golom-si\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-11-16T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:00:38+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438 | ProHoster","description":"\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439) \u2014 \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445: Node.js Tor Transmission Chromium Memcached ... \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u043d\u043e\u0433\u043e\u0442\u043d\u0443\u044e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u043c\u0438\u043d. \u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/polnofunktsionalnyj-i-o-reaktor-na-golom-si","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"sq_AL","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0433\u043e\u043b\u043e\u043c \u0421\u0438 | ProHoster","og:description":"\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440 (\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u0431\u044b\u0442\u0438\u0439) \u2014 \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445: Node.js Tor Transmission Chromium Memcached ... \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u043d\u043e\u0433\u043e\u0442\u043d\u0443\u044e I\/O \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 200 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u044b\u0448\u0435 40 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u043c\u0438\u043d. \u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/polnofunktsionalnyj-i-o-reaktor-na-golom-si","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-11-16T21:00:00+00:00","article:modified_time":"2020-02-18T11:00:38+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"52833","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 05:03:20","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 20:36:36","updated":"2026-01-24 05:03:20"},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/52833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/comments?post=52833"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/52833\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=52833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=52833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=52833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}