{"id":262312,"date":"2015-07-27T08:50:02","date_gmt":"2015-07-27T04:50:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=262312"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=262312","title":{"rendered":"\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 SOCKS 4 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Qt"},"content":{"rendered":"<p>     \t\u0412\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0430\u0445 \u0440\u0443\u043d\u0435\u0442\u0430 \u0432 \u0432\u0435\u0442\u043a\u0435 Qt \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0435\u0440\u0437\u0430\u0435\u0442 \u044d\u0442\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442 \u0442\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:  <\/p>\n<ul>\n<li>\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439;<\/li>\n<li>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u043f\u043e\u0442\u043e\u043a\u0443 \u043d\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435;<\/li>\n<li>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439, \u0441 \u043f\u0443\u043b\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 <a href=\"http:\/\/doc.qt.io\/qt-5\/qthreadpool.html\">QThreadPool<\/a> \u0438 <a href=\"http:\/\/doc.qt.io\/qt-5\/qrunnable.html\">QRunnable<\/a>.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0448\u044c \u043f\u0440\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0442\u043e \u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440. \u0414\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u043f\u0443\u043b\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 \u0446\u0438\u043a\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043b\u0438\u0446\u0430:  <\/p>\n<ul>\n<li>\u043a\u043b\u0430\u0441\u0441 <b>Server<\/b>, \u043f\u0440\u0438\u043c\u0438\u043d\u0430\u044e\u0449\u0438\u0439 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u043c;<\/li>\n<li>\u043a\u043b\u0430\u0441\u0441 <b>Worker<\/b>, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 Client;<\/li>\n<li>\u043a\u043b\u0430\u0441\u0441 <b>Client<\/b> \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 SOCKS 4<\/li>\n<\/ul>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0442\u0440\u043e\u0438\u0446\u044b Worker, \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <b>QObject<\/b> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0447\u0438\u0441\u0442\u043e \u0434\u043b\u044f \u00ab\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e\u00bb <a href=\"http:\/\/habrahabr.ru\/post\/150274\/\">\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/a>:  <\/p>\n<pre><code class=\"cpp\">class Worker: public QObject { Q_OBJECT  public:      Q_INVOKABLE void addClient(qintptr socketDescriptor); }; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">void Worker::addClient(qintptr socketDescriptor) {     new Client(socketDescriptor, this); } <\/code><\/pre>\n<p>  \u0421\u0435\u0440\u0432\u0435\u0440 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0441\u0442:  <\/p>\n<pre><code class=\"cpp\">class Server: public QTcpServer { Q_OBJECT  public:      Server(size_t threads = 4, QObject * parent = nullptr);     ~Server();  protected:      virtual void incomingConnection(qintptr socketDescriptor);  private:      void initThreads();  private:      size_t m_threadCount;      QVector&lt;QThread*&gt; m_threads;     QVector&lt;Worker*&gt; m_workers;     size_t m_rrcounter; }; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">Server::Server(size_t threads, QObject * parent) :         QTcpServer(parent),         m_threadCount(threads),         m_rrcounter(0) {     initThreads(); }  Server::~Server() {     for(QThread* thread: m_threads)     {         thread-&gt;quit();         thread-&gt;wait();     } }  void Server::initThreads() {     for (size_t i = 0; i &lt; m_threadCount; ++i)     {         QThread* thread = new QThread(this);          Worker* worker = new Worker();         worker-&gt;moveToThread(thread);         connect(thread, &QThread::finished,                 worker, &QObject::deleteLater);          m_threads.push_back(thread);         m_workers.push_back(worker);          thread-&gt;start();     } }  void Server::incomingConnection(qintptr socketDescriptor) {     Worker* worker = m_workers[m_rrcounter % m_threadCount];     ++m_rrcounter;      QMetaObject::invokeMethod(worker, &quot;addClient&quot;,             Qt::QueuedConnection,             Q_ARG(qintptr, socketDescriptor)); } <\/code><\/pre>\n<p>  \u041e\u043d \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0438, \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0432 \u043f\u043e\u0442\u043e\u043a\u0438. \u041a\u0430\u0436\u0434\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443. \u0420\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043e\u043d \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u00ab\u043f\u043e\u0447\u0435\u0441\u0442\u043d\u043e\u043a\u0443\u00bb, \u0442. \u0435. \u043f\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Round-robin_%28%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%29\">Round-robin<\/a>.<\/p>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/SOCKS#.D0.9F.D1.80.D0.BE.D1.82.D0.BE.D0.BA.D0.BE.D0.BB_SOCKS_4\">SOCKS 4<\/a> \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c:  <\/p>\n<ol>\n<li>\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c IP-\u0430\u0434\u0440\u0435\u0441, \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430;<\/li>\n<li>\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u00ab\u043c\u0438\u0440\u043e\u043c\u00bb;<\/li>\n<li>\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d;<\/li>\n<li>\u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u043a\u0435\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439, \u043f\u043e\u043a\u0430 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0435 \u0437\u0430\u043a\u0440\u043e\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"cpp\">class Client: public QObject { Q_OBJECT  public:      Client(qintptr socketDescriptor, QObject* parent = 0);  public slots:      void onRequest();      void client2world();     void world2client();      void sendSocksAnsver();      void onClientDisconnected();     void onWorldDisconnected();  private:      void done();  private:      QTcpSocket m_client;     QTcpSocket m_world; }; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">namespace { #pragma pack(push, 1)     struct socks4request     {         uint8_t version;         uint8_t command;         uint16_t port;         uint32_t address;         uint8_t end;     };      struct socks4ansver     {         uint8_t empty = 0;         uint8_t status;         uint16_t field1 = 0;         uint32_t field2 = 0;     }; #pragma pack(pop)      enum SocksStatus     {         Granted = 0x5a,         Failed = 0x5b,         Failed_no_identd = 0x5c,         Failed_bad_user_id = 0x5d     }; } Client::Client(qintptr socketDescriptor, QObject* parent) :         QObject(parent) {     m_client.setSocketDescriptor(socketDescriptor);      connect(&m_client, &QTcpSocket::readyRead,             this, &Client::onRequest);      connect(&m_client,&QTcpSocket::disconnected,             this, &Client::onClientDisconnected);      connect(&m_world, &QTcpSocket::connected,             this, &Client::sendSocksAnsver);      connect(&m_world, &QTcpSocket::readyRead,             this, &Client::world2client);      connect(&m_world,&QTcpSocket::disconnected,             this, &Client::onWorldDisconnected); }  void Client::onRequest() {     QByteArray request = m_client.readAll();      socks4request* header = reinterpret_cast&lt;socks4request*&gt;(request.data());  #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN     const QHostAddress address(qFromBigEndian(header-&gt;address)); #else     const QHostAddress address(header-&gt;address); #endif  #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN     const uint16_t port = qFromBigEndian(header-&gt;port); #else     const uint16_t port = header-&gt;port; #endif     \/\/qDebug()&lt;&lt;&quot;connection:&quot;&lt;&lt;address&lt;&lt;&quot;port:&quot;&lt;&lt;port;      m_world.connectToHost(address, port);      disconnect(&m_client, &QTcpSocket::readyRead, this,             &Client::onRequest);      connect(&m_client, &QTcpSocket::readyRead, this,             &Client::client2world); }  void Client::sendSocksAnsver() {     socks4ansver ans;     ans.status = Granted;     m_client.write(reinterpret_cast&lt;char*&gt;(&ans), sizeof(ans));     m_client.flush(); }  void Client::client2world() {     m_world.write(m_client.readAll()); }  void Client::world2client() {     m_client.write(m_world.readAll()); }  void Client::onClientDisconnected() {     m_world.flush();      done(); }  void Client::onWorldDisconnected() {     m_client.flush();      done(); }  void Client::done() {     m_client.close();     m_world.close();      deleteLater(); } <\/code><\/pre>\n<p>  <\/p>\n<h5><b>Epoll \u0438 Qt<\/b><\/h5>\n<p>  <\/p>\n<blockquote><p>\u041a\u0440\u0438\u043a \u043f\u043e\u0434\u043e\u0431\u0435\u043d \u0433\u0440\u043e\u043c\u0443:<br \/>   \u2014 \u0414\u0430\u0439\u0442\u0435 \u043b\u044e\u0434\u044f\u043c \u0440\u043e\u043c\u0443<br \/>  \u041d\u0443\u0436\u043d\u043e \u043f\u043e \u043b\u044e\u0431\u043e\u043c\u0443<br \/>  \u041b\u044e\u0434\u044f\u043c \u0432\u044b\u043f\u0438\u0442\u044c \u0440\u043e\u043c\u0443!  <\/p><\/blockquote>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u0434 \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 <b>strace -f<\/b>, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u044b poll. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0439\u0434\u0435\u0442\u0441\u044f \u043a\u0442\u043e-\u0442\u043e, \u043a\u0442\u043e \u0441\u043a\u0430\u0436\u0435\u0442 \u0441\u0432\u043e\u0451 \u0432\u0435\u0441\u043a\u043e\u0435 \u00ab\u0444\u0438\u00bb, \u043c\u043e\u043b \u0441 epoll \u0431\u0443\u0434\u0435\u0442 \u00ab\u043d\u0443 \u0432\u0430\u0449\u0435 \u0440\u0430\u043a\u0435\u0442\u0430\u00bb. <\/p>\n<p>  \u0412 Qt \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <a href=\"http:\/\/doc.qt.io\/qt-5\/qabstracteventdispatcher.html\">QAbstractEventDispatcher<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0448\u043b\u0438\u0441\u044c \u0434\u043e\u0431\u0440\u044b\u0435 \u043b\u044e\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0438 \u0432\u044b\u043b\u043e\u0436\u0438\u043b\u0438 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0431\u0435\u043a\u0435\u043d\u0434. \u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0445 \u0441\u043f\u0438\u0441\u043e\u043a:  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/connectedtable\/qeventdispatcher_epoll\">connectedtable\/qeventdispatcher_epoll<\/a>;<\/li>\n<li><a href=\"https:\/\/github.com\/sjinks\/qt_eventdispatcher_epoll\">sjinks\/qt_eventdispatcher_epoll<\/a>;<\/li>\n<li><a href=\"https:\/\/github.com\/sjinks\/qt_eventdispatcher_libev\">sjinks\/qt_eventdispatcher_libev<\/a>;<\/li>\n<li><a href=\"https:\/\/github.com\/sjinks\/qt_eventdispatcher_libevent\">sjinks\/qt_eventdispatcher_libevent<\/a><\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430 \u0432 main.cpp \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c  <\/p>\n<pre><code class=\"cpp\">QCoreApplication::setEventDispatcher(new QEventDispatcherEpoll); QCoreApplication app(argc, argv) <\/code><\/pre>\n<p>  \u0430 \u043c\u0435\u0442\u043e\u0434 initThreads \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c:  <\/p>\n<pre><code class=\"cpp\">void Server::initThreads() {     for (size_t i = 0; i &lt; m_threadCount; ++i)     {         QThread* thread = new QThread(this);         thread-&gt;setEventDispatcher(new QEventDispatcherEpoll);         Worker* worker = new Worker();         worker-&gt;moveToThread(thread);         connect(thread, &QThread::finished,                 worker, &QObject::deleteLater);          m_threads.push_back(thread);         m_workers.push_back(worker);          thread-&gt;start();     } } <\/code><\/pre>\n<p>  \u0418 \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c strace, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <b>epoll_<\/b>.<\/p>\n<h5><b>\u0412\u044b\u0432\u043e\u0434\u044b<\/b><\/h5>\n<p>  \u0412\u044b\u0432\u043e\u0434\u044b \u0441\u0443\u0433\u0443\u0431\u043e \u043f\u0440\u0430\u0433\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u00ab\u0431\u043e\u043b\u044c\u0448\u0438\u0445\u00bb \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 highload \u043f\u043e \u0411\u0443\u043d\u0438\u043d\u0443, \u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 \u0447\u0435\u043c \u0445\u043e\u0442\u0438\u0442\u0435 \u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442\u0435. \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0432\u044b\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430, \u0437\u0430\u0442\u0440\u0430\u0442\u0438\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0434\u043d\u0438\u043c\u0438 \u043b\u0438\u0448\u044c \u0441\u043e\u043a\u0435\u0442\u0430\u043c\u0438 \u0441 epoll \u043d\u0435 \u043e\u0431\u043e\u0439\u0434\u0435\u0448\u044c\u0441\u044f.<\/p>\n<p>  P.S.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <a href=\"https:\/\/github.com\/RPG-18\/qtsocks\">GitHub<\/a>.     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/263549\/\"> http:\/\/habrahabr.ru\/post\/263549\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u0412\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0430\u0445 \u0440\u0443\u043d\u0435\u0442\u0430 \u0432 \u0432\u0435\u0442\u043a\u0435 Qt \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0435\u0440\u0437\u0430\u0435\u0442 \u044d\u0442\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u044d\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442 \u0442\u0440\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:  <\/p>\n<ul>\n<li>\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439;<\/li>\n<li>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u043f\u043e\u0442\u043e\u043a\u0443 \u043d\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435;<\/li>\n<li>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439, \u0441 \u043f\u0443\u043b\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0430 <a href=\"http:\/\/doc.qt.io\/qt-5\/qthreadpool.html\">QThreadPool<\/a> \u0438 <a href=\"http:\/\/doc.qt.io\/qt-5\/qrunnable.html\">QRunnable<\/a>.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0448\u044c \u043f\u0440\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0442\u043e \u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440. \u0414\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u043f\u0443\u043b\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 \u0446\u0438\u043a\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-262312","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/262312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=262312"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/262312\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=262312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=262312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=262312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}