| 1 |
# Russian translation of manpages |
| 2 |
# This file is distributed under the same license as the manpages-l10n package. |
| 3 |
# Copyright © of this file: |
| 4 |
# Alexander Golubev <[email protected]>, 2018. |
| 5 |
# Azamat Hackimov <[email protected]>, 2011, 2014-2016. |
| 6 |
# Hotellook, 2014. |
| 7 |
# Nikita <[email protected]>, 2014. |
| 8 |
# Spiros Georgaras <[email protected]>, 2016. |
| 9 |
# Vladislav <[email protected]>, 2015. |
| 10 |
# Yuri Kozlov <[email protected]>, 2011-2019. |
| 11 |
# Иван Павлов <[email protected]>, 2017. |
| 12 |
msgid "" |
| 13 |
msgstr "" |
| 14 |
"Project-Id-Version: manpages-l10n\n" |
| 15 |
"POT-Creation-Date: 2026-06-05 06:42+0200\n" |
| 16 |
"PO-Revision-Date: 2024-12-21 19:49+0300\n" |
| 17 |
"Last-Translator: Yuri Kozlov <[email protected]>\n" |
| 18 |
"Language-Team: Russian <[email protected]>\n" |
| 19 |
"Language: ru\n" |
| 20 |
"MIME-Version: 1.0\n" |
| 21 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 22 |
"Content-Transfer-Encoding: 8bit\n" |
| 23 |
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " |
| 24 |
"n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || " |
| 25 |
"(n%100>=11 && n%100<=14)? 2 : 3);\n" |
| 26 |
"X-Generator: Lokalize 2.0\n" |
| 27 |
|
| 28 |
#. type: TH |
| 29 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 30 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 31 |
#, no-wrap |
| 32 |
msgid "SELECT_TUT" |
| 33 |
msgstr "SELECT_TUT" |
| 34 |
|
| 35 |
#. type: TH |
| 36 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 37 |
#: opensuse-tumbleweed |
| 38 |
#, no-wrap |
| 39 |
msgid "2026-02-08" |
| 40 |
msgstr "8 февраля 2026 г." |
| 41 |
|
| 42 |
#. type: TH |
| 43 |
#: archlinux debian-unstable |
| 44 |
#, fuzzy, no-wrap |
| 45 |
#| msgid "Linux man-pages 6.17" |
| 46 |
msgid "Linux man-pages 6.18" |
| 47 |
msgstr "Справочные страницы Linux 6.17" |
| 48 |
|
| 49 |
#. type: SH |
| 50 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 51 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 52 |
#, no-wrap |
| 53 |
msgid "NAME" |
| 54 |
msgstr "НАИМЕНОВАНИЕ" |
| 55 |
|
| 56 |
#. type: Plain text |
| 57 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 58 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 59 |
msgid "select, pselect - synchronous I/O multiplexing" |
| 60 |
msgstr "select, pselect - многопоточный синхронный ввод-вывод" |
| 61 |
|
| 62 |
#. type: SH |
| 63 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 64 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 65 |
#, no-wrap |
| 66 |
msgid "LIBRARY" |
| 67 |
msgstr "БИБЛИОТЕКА" |
| 68 |
|
| 69 |
#. type: Plain text |
| 70 |
#: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron |
| 71 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 72 |
msgid "Standard C library (I<libc>,\\ I<-lc>)" |
| 73 |
msgstr "Стандартная библиотека языка C (I<libc>,\\ I<-lc>)" |
| 74 |
|
| 75 |
#. type: SH |
| 76 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 77 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 78 |
#, no-wrap |
| 79 |
msgid "SYNOPSIS" |
| 80 |
msgstr "СИНТАКСИС" |
| 81 |
|
| 82 |
#. type: Plain text |
| 83 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 84 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 85 |
msgid "See B<select>(2)" |
| 86 |
msgstr "Смотрите B<select>(2)" |
| 87 |
|
| 88 |
#. type: SH |
| 89 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 90 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 91 |
#, no-wrap |
| 92 |
msgid "DESCRIPTION" |
| 93 |
msgstr "ОПИСАНИЕ" |
| 94 |
|
| 95 |
#. type: Plain text |
| 96 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 97 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 98 |
#, fuzzy |
| 99 |
#| msgid "" |
| 100 |
#| "B<select>() (or B<pselect>()) is used to efficiently monitor multiple " |
| 101 |
#| "file descriptors, to see if any of them is, or becomes, \"ready\"; that " |
| 102 |
#| "is, to see whether I/O becomes possible, or an \"exceptional condition\" " |
| 103 |
#| "has occurred on any of the file descriptors." |
| 104 |
msgid "" |
| 105 |
"The B<select>() and B<pselect>() system calls are used to efficiently " |
| 106 |
"monitor multiple file descriptors, to see if any of them is, or becomes, " |
| 107 |
"\"ready\"; that is, to see whether I/O becomes possible, or an \"exceptional " |
| 108 |
"condition\" has occurred on any of the file descriptors." |
| 109 |
msgstr "" |
| 110 |
"Вызов B<select>() (или B<pselect>()) используется для эффективного слежения " |
| 111 |
"за несколькими файловыми дескрипторами — для ожидания, когда какой-то из них " |
| 112 |
"не станет «готов», то есть появится возможность чтения-записи данных, или с " |
| 113 |
"файловым дескриптором не возникнет «исключительная ситуация»." |
| 114 |
|
| 115 |
#. type: Plain text |
| 116 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 117 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 118 |
msgid "" |
| 119 |
"This page provides background and tutorial information on the use of these " |
| 120 |
"system calls. For details of the arguments and semantics of B<select>() " |
| 121 |
"and B<pselect>(), see B<select>(2)." |
| 122 |
msgstr "" |
| 123 |
|
| 124 |
#. type: SS |
| 125 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 126 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 127 |
#, no-wrap |
| 128 |
msgid "Combining signal and data events" |
| 129 |
msgstr "Комбинирование событий сигналов и данных" |
| 130 |
|
| 131 |
#. type: Plain text |
| 132 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 133 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 134 |
msgid "" |
| 135 |
"B<pselect>() is useful if you are waiting for a signal as well as for file " |
| 136 |
"descriptor(s) to become ready for I/O. Programs that receive signals " |
| 137 |
"normally use the signal handler only to raise a global flag. The global " |
| 138 |
"flag will indicate that the event must be processed in the main loop of the " |
| 139 |
"program. A signal will cause the B<select>() (or B<pselect>()) call to " |
| 140 |
"return with I<errno> set to B<EINTR>. This behavior is essential so that " |
| 141 |
"signals can be processed in the main loop of the program, otherwise " |
| 142 |
"B<select>() would block indefinitely." |
| 143 |
msgstr "" |
| 144 |
|
| 145 |
#. type: Plain text |
| 146 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 147 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 148 |
#, fuzzy |
| 149 |
#| msgid "" |
| 150 |
#| "B<pselect>() is useful if you are waiting for a signal as well as for " |
| 151 |
#| "file descriptor(s) to become ready for I/O. Programs that receive " |
| 152 |
#| "signals normally use the signal handler only to raise a global flag. The " |
| 153 |
#| "global flag will indicate that the event must be processed in the main " |
| 154 |
#| "loop of the program. A signal will cause the B<select>() (or " |
| 155 |
#| "B<pselect>()) call to return with I<errno> set to B<EINTR>. This " |
| 156 |
#| "behavior is essential so that signals can be processed in the main loop " |
| 157 |
#| "of the program, otherwise B<select>() would block indefinitely. Now, " |
| 158 |
#| "somewhere in the main loop will be a conditional to check the global " |
| 159 |
#| "flag. So we must ask: what if a signal arrives after the conditional, " |
| 160 |
#| "but before the B<select>() call? The answer is that B<select>() would " |
| 161 |
#| "block indefinitely, even though an event is actually pending. This race " |
| 162 |
#| "condition is solved by the B<pselect>() call. This call can be used to " |
| 163 |
#| "set the signal mask to a set of signals that are to be received only " |
| 164 |
#| "within the B<pselect>() call. For instance, let us say that the event " |
| 165 |
#| "in question was the exit of a child process. Before the start of the " |
| 166 |
#| "main loop, we would block B<SIGCHLD> using B<sigprocmask>(2). Our " |
| 167 |
#| "B<pselect>() call would enable B<SIGCHLD> by using an empty signal " |
| 168 |
#| "mask. Our program would look like:" |
| 169 |
msgid "" |
| 170 |
"Now, somewhere in the main loop will be a conditional to check the global " |
| 171 |
"flag. So we must ask: what if a signal arrives after the conditional, but " |
| 172 |
"before the B<select>() call? The answer is that B<select>() would block " |
| 173 |
"indefinitely, even though an event is actually pending. This race condition " |
| 174 |
"is solved by the B<pselect>() call. This call can be used to set the " |
| 175 |
"signal mask to a set of signals that are to be received only within the " |
| 176 |
"B<pselect>() call. For instance, let us say that the event in question was " |
| 177 |
"the exit of a child process. Before the start of the main loop, we would " |
| 178 |
"block B<SIGCHLD> using B<sigprocmask>(2). Our B<pselect>() call would " |
| 179 |
"enable B<SIGCHLD> by using an empty signal mask. Our program would look " |
| 180 |
"like:" |
| 181 |
msgstr "" |
| 182 |
"Вызов B<pselect>() полезен как для ожидания сигнала, так и для ожидания " |
| 183 |
"готовности файлового дескриптора для ввода-вывода. Программы, принимающие " |
| 184 |
"сигналы, как правило, лишь выставляют в обработчике сигнала глобальный флаг, " |
| 185 |
"который означает, что требуется обработка события в главном цикле программы. " |
| 186 |
"Появление сигнала заставит вызов B<select>() (или B<pselect>()) вернуть " |
| 187 |
"управление вызвавшей программе; при этом I<errno> будет присвоено B<EINTR>. " |
| 188 |
"Это поведение продиктовано необходимостью обработки сигналов в главном цикле " |
| 189 |
"программы во избежание бесконечной блокировки B<select>(). В главном цикле " |
| 190 |
"программы должно быть условие, проверяющее глобальный флаг. Возникает " |
| 191 |
"вопрос: а что если сигнал придёт после проверки этого условия, но до вызова " |
| 192 |
"B<select>()? В этом случае программа навсегда останется в B<select>(), хотя " |
| 193 |
"и есть ожидающее событие. Для разрешения этой проблемы существует вызов " |
| 194 |
"B<pselect>(). Этот вызов можно использовать для установки в сигнальной маске " |
| 195 |
"сигналов, которые принимаются только внутри вызова B<pselect>(). Например, " |
| 196 |
"предположим что интересующее нас событие — это завершение дочернего " |
| 197 |
"процесса. Перед запуском главного цикла заблокируем B<SIGCHLD> с помощью " |
| 198 |
"B<sigprocmask>(2). Наш вызов B<pselect>() разблокирует B<SIGCHLD>, указав " |
| 199 |
"пустую маску сигналов. Программа будет выглядеть так:" |
| 200 |
|
| 201 |
#. type: Plain text |
| 202 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 203 |
#: opensuse-tumbleweed |
| 204 |
#, no-wrap |
| 205 |
msgid "" |
| 206 |
"static volatile sig_atomic_t got_SIGCHLD = 0;\n" |
| 207 |
"\\&\n" |
| 208 |
"static void\n" |
| 209 |
"child_sig_handler(int sig)\n" |
| 210 |
"{\n" |
| 211 |
" got_SIGCHLD = 1;\n" |
| 212 |
"}\n" |
| 213 |
"\\&\n" |
| 214 |
"int\n" |
| 215 |
"main(int argc, char *argv[])\n" |
| 216 |
"{\n" |
| 217 |
" sigset_t sigmask, empty_mask;\n" |
| 218 |
" struct sigaction sa;\n" |
| 219 |
" fd_set readfds, writefds, exceptfds;\n" |
| 220 |
" int r;\n" |
| 221 |
"\\&\n" |
| 222 |
" sigemptyset(&sigmask);\n" |
| 223 |
" sigaddset(&sigmask, SIGCHLD);\n" |
| 224 |
" if (sigprocmask(SIG_BLOCK, &sigmask, NULL) == -1) {\n" |
| 225 |
" perror(\"sigprocmask\");\n" |
| 226 |
" exit(EXIT_FAILURE);\n" |
| 227 |
" }\n" |
| 228 |
"\\&\n" |
| 229 |
" sa.sa_flags = 0;\n" |
| 230 |
" sa.sa_handler = child_sig_handler;\n" |
| 231 |
" sigemptyset(&sa.sa_mask);\n" |
| 232 |
" if (sigaction(SIGCHLD, &sa, NULL) == -1) {\n" |
| 233 |
" perror(\"sigaction\");\n" |
| 234 |
" exit(EXIT_FAILURE);\n" |
| 235 |
" }\n" |
| 236 |
"\\&\n" |
| 237 |
" sigemptyset(&empty_mask);\n" |
| 238 |
"\\&\n" |
| 239 |
" for (;;) { /* main loop */\n" |
| 240 |
" /* Initialize readfds, writefds, and exceptfds\n" |
| 241 |
" before the pselect() call. (Code omitted.) */\n" |
| 242 |
"\\&\n" |
| 243 |
" r = pselect(nfds, &readfds, &writefds, &exceptfds,\n" |
| 244 |
" NULL, &empty_mask);\n" |
| 245 |
" if (r == -1 && errno != EINTR) {\n" |
| 246 |
" /* Handle error */\n" |
| 247 |
" }\n" |
| 248 |
"\\&\n" |
| 249 |
" if (got_SIGCHLD) {\n" |
| 250 |
" got_SIGCHLD = 0;\n" |
| 251 |
"\\&\n" |
| 252 |
" /* Handle signalled event here; e.g., wait() for all\n" |
| 253 |
" terminated children. (Code omitted.) */\n" |
| 254 |
" }\n" |
| 255 |
"\\&\n" |
| 256 |
" /* main body of program */\n" |
| 257 |
" }\n" |
| 258 |
"}\n" |
| 259 |
msgstr "" |
| 260 |
|
| 261 |
#. type: SS |
| 262 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 263 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 264 |
#, no-wrap |
| 265 |
msgid "Practical" |
| 266 |
msgstr "Практика" |
| 267 |
|
| 268 |
#. type: Plain text |
| 269 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 270 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 271 |
msgid "" |
| 272 |
"So what is the point of B<select>()? Can't I just read and write to my file " |
| 273 |
"descriptors whenever I want? The point of B<select>() is that it watches " |
| 274 |
"multiple descriptors at the same time and properly puts the process to sleep " |
| 275 |
"if there is no activity. UNIX programmers often find themselves in a " |
| 276 |
"position where they have to handle I/O from more than one file descriptor " |
| 277 |
"where the data flow may be intermittent. If you were to merely create a " |
| 278 |
"sequence of B<read>(2) and B<write>(2) calls, you would find that one of " |
| 279 |
"your calls may block waiting for data from/to a file descriptor, while " |
| 280 |
"another file descriptor is unused though ready for I/O. B<select>() " |
| 281 |
"efficiently copes with this situation." |
| 282 |
msgstr "" |
| 283 |
"Итак, какой прок от использования B<select>()? Разве нельзя просто считывать " |
| 284 |
"и записывать данные в файловые дескрипторы когда этого захочется? Смысл " |
| 285 |
"использования B<select>() в том, что он позволяет следит за несколькими " |
| 286 |
"дескрипторами одновременно и корректно переводить процесс в режим ожидания, " |
| 287 |
"когда активности не наблюдается. Программисты UNIX часто попадают в " |
| 288 |
"ситуацию, когда необходимо обработать ввод-вывод из более чем одного " |
| 289 |
"файлового дескриптора в то время как поток данных может быть неравномерным. " |
| 290 |
"Если вы просто создадите последовательность вызовов B<read>(2) и " |
| 291 |
"B<write>(2), то можете попасть в ситуацию, когда один из вызовов будет " |
| 292 |
"ожидать данные из/в файлового дескриптора, в то время как другой будет " |
| 293 |
"простаивать, хотя данные для него уже появились. Вызов B<select>() позволяет " |
| 294 |
"эффективно справиться с такой ситуацией." |
| 295 |
|
| 296 |
#. type: SS |
| 297 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 298 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 299 |
#, no-wrap |
| 300 |
msgid "Select law" |
| 301 |
msgstr "Правила использования" |
| 302 |
|
| 303 |
#. type: Plain text |
| 304 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 305 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 306 |
msgid "" |
| 307 |
"Many people who try to use B<select>() come across behavior that is " |
| 308 |
"difficult to understand and produces nonportable or borderline results. For " |
| 309 |
"instance, the above program is carefully written not to block at any point, " |
| 310 |
"even though it does not set its file descriptors to nonblocking mode. It is " |
| 311 |
"easy to introduce subtle errors that will remove the advantage of using " |
| 312 |
"B<select>(), so here is a list of essentials to watch for when using " |
| 313 |
"B<select>()." |
| 314 |
msgstr "" |
| 315 |
"Многие из тех, кто пытался использовать B<select>(), сталкивались с " |
| 316 |
"поведением, которое трудно понять, и которое приводило к непереносимым или " |
| 317 |
"просто плохим результатам. Например, вышеприведенная программа тщательно " |
| 318 |
"спланирована так, чтобы ни в каком случае не блокироваться, хотя для её " |
| 319 |
"файловых дескрипторов не установлен неблокирующий режим. Несложно " |
| 320 |
"перечислить не очевидные ошибки, которые лишат всех преимуществ " |
| 321 |
"использования B<select>(), поэтому вот список основных моментов, на которые " |
| 322 |
"нужно обращать внимание при использовании B<select>()." |
| 323 |
|
| 324 |
#. type: TP |
| 325 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 326 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 327 |
#, no-wrap |
| 328 |
msgid "1." |
| 329 |
msgstr "1." |
| 330 |
|
| 331 |
#. type: Plain text |
| 332 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 333 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 334 |
msgid "" |
| 335 |
"You should always try to use B<select>() without a timeout. Your program " |
| 336 |
"should have nothing to do if there is no data available. Code that depends " |
| 337 |
"on timeouts is not usually portable and is difficult to debug." |
| 338 |
msgstr "" |
| 339 |
"Всегда старайтесь использовать B<select>() без указания времени ожидания. " |
| 340 |
"Ваша программа не должна ничего делать, если нет данных. Код, зависимый от " |
| 341 |
"времени ожидания, обычно плохо переносим и сложен для отладки." |
| 342 |
|
| 343 |
#. type: TP |
| 344 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 345 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 346 |
#, no-wrap |
| 347 |
msgid "2." |
| 348 |
msgstr "2." |
| 349 |
|
| 350 |
#. type: Plain text |
| 351 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 352 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 353 |
msgid "" |
| 354 |
"The value I<nfds> must be properly calculated for efficiency as explained " |
| 355 |
"above." |
| 356 |
msgstr "" |
| 357 |
"Для повышения эффективности значение I<nfds> должно правильно вычисляться, " |
| 358 |
"как это объяснялось выше." |
| 359 |
|
| 360 |
#. type: TP |
| 361 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 362 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 363 |
#, no-wrap |
| 364 |
msgid "3." |
| 365 |
msgstr "3." |
| 366 |
|
| 367 |
#. type: Plain text |
| 368 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 369 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 370 |
msgid "" |
| 371 |
"No file descriptor must be added to any set if you do not intend to check " |
| 372 |
"its result after the B<select>() call, and respond appropriately. See next " |
| 373 |
"rule." |
| 374 |
msgstr "" |
| 375 |
"Файловые дескрипторы не должны добавляться в наборы, если вы не планируете " |
| 376 |
"после вызова B<select>() проверять результат и соответствующим образом " |
| 377 |
"реагировать. Смотрите следующее правило." |
| 378 |
|
| 379 |
#. type: TP |
| 380 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 381 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 382 |
#, no-wrap |
| 383 |
msgid "4." |
| 384 |
msgstr "4." |
| 385 |
|
| 386 |
#. type: Plain text |
| 387 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 388 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 389 |
msgid "" |
| 390 |
"After B<select>() returns, all file descriptors in all sets should be " |
| 391 |
"checked to see if they are ready." |
| 392 |
msgstr "" |
| 393 |
"После возврата из B<select>() должны быть проверены все файловые дескрипторы " |
| 394 |
"во всех наборах." |
| 395 |
|
| 396 |
#. type: TP |
| 397 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 398 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 399 |
#, no-wrap |
| 400 |
msgid "5." |
| 401 |
msgstr "5." |
| 402 |
|
| 403 |
#. type: Plain text |
| 404 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 405 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 406 |
msgid "" |
| 407 |
"The functions B<read>(2), B<recv>(2), B<write>(2), and B<send>(2) do I<not> " |
| 408 |
"necessarily read/write the full amount of data that you have requested. If " |
| 409 |
"they do read/write the full amount, it's because you have a low traffic load " |
| 410 |
"and a fast stream. This is not always going to be the case. You should " |
| 411 |
"cope with the case of your functions managing to send or receive only a " |
| 412 |
"single byte." |
| 413 |
msgstr "" |
| 414 |
"Вызовы B<read>(2), B<recv>(2), B<write>(2) и B<send>(2) I<не> обязательно " |
| 415 |
"считывают/записывают данные в полном объёме. Такое, конечно, возможно при " |
| 416 |
"низком трафике или быстром потоке, однако происходит далеко не всегда. Вы " |
| 417 |
"должны рассчитывать, что ваши функции получают/отправляют только один байт " |
| 418 |
"за раз." |
| 419 |
|
| 420 |
#. type: TP |
| 421 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 422 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 423 |
#, no-wrap |
| 424 |
msgid "6." |
| 425 |
msgstr "6." |
| 426 |
|
| 427 |
#. type: Plain text |
| 428 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 429 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 430 |
msgid "" |
| 431 |
"Never read/write only in single bytes at a time unless you are really sure " |
| 432 |
"that you have a small amount of data to process. It is extremely " |
| 433 |
"inefficient not to read/write as much data as you can buffer each time. The " |
| 434 |
"buffers in the example below are 1024 bytes although they could easily be " |
| 435 |
"made larger." |
| 436 |
msgstr "" |
| 437 |
"Никогда не считывайте/записывайте побайтно, если только вы не абсолютно " |
| 438 |
"уверены в том, что нужно обработать небольшой объём данных. Крайне " |
| 439 |
"неэффективно считывать/записывать меньшее количество байт, чем вы можете " |
| 440 |
"поместить в буфер за один раз. Буферы в вышеприведённом примере имеют размер " |
| 441 |
"1024 байта, однако могут быть легко увеличены до максимального размера " |
| 442 |
"пакета в вашей локальной сети." |
| 443 |
|
| 444 |
#. type: TP |
| 445 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 446 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 447 |
#, no-wrap |
| 448 |
msgid "7." |
| 449 |
msgstr "7." |
| 450 |
|
| 451 |
#. Nonetheless, you should still cope with these errors for completeness. |
| 452 |
#. type: Plain text |
| 453 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 454 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 455 |
#, fuzzy |
| 456 |
#| msgid "" |
| 457 |
#| "Calls to B<read>(2), B<recv>(2), B<write>(2), B<send>(2), and " |
| 458 |
#| "B<select>() can fail with the error B<EINTR>, and calls to B<read>(2), " |
| 459 |
#| "B<recv>(2) B<write>(2), and B<send>(2) can fail with I<errno> set to " |
| 460 |
#| "B<EAGAIN> (B<EWOULDBLOCK>). These results must be properly managed (not " |
| 461 |
#| "done properly above). If your program is not going to receive any " |
| 462 |
#| "signals, then it is unlikely you will get B<EINTR>. If your program does " |
| 463 |
#| "not set nonblocking I/O, you will not get B<EAGAIN>." |
| 464 |
msgid "" |
| 465 |
"Calls to B<read>(2), B<recv>(2), B<write>(2), B<send>(2), and B<select>() " |
| 466 |
"can fail with the error B<EINTR>, and calls to B<read>(2), B<recv>(2), " |
| 467 |
"B<write>(2), and B<send>(2) can fail with I<errno> set to B<EAGAIN> " |
| 468 |
"(B<EWOULDBLOCK>). These results must be properly managed (not done properly " |
| 469 |
"above). If your program is not going to receive any signals, then it is " |
| 470 |
"unlikely you will get B<EINTR>. If your program does not set nonblocking I/" |
| 471 |
"O, you will not get B<EAGAIN>." |
| 472 |
msgstr "" |
| 473 |
"Вызовы B<read>(2), B<recv>(2), B<write>(2), B<send>(2) и B<select>() могут " |
| 474 |
"завершиться ошибкой B<EINTR>, а вызовы B<read>(2), B<recv>(2) B<write>(2) и " |
| 475 |
"B<send>(2) могут завершиться присвоением I<errno> значения B<EAGAIN> " |
| 476 |
"(B<EWOULDBLOCK>). Эти варианты должны быть правильно обработаны (в " |
| 477 |
"вышеприведенной программе этого не сделано). Если ваша программа не " |
| 478 |
"собирается принимать сигналы, то маловероятно, что вы получите B<EINTR>. " |
| 479 |
"Если ваша программа не использует неблокирующий ввод-вывод, то вы не " |
| 480 |
"получите B<EAGAIN>." |
| 481 |
|
| 482 |
#. type: TP |
| 483 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 484 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 485 |
#, no-wrap |
| 486 |
msgid "8." |
| 487 |
msgstr "8." |
| 488 |
|
| 489 |
#. type: Plain text |
| 490 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 491 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 492 |
msgid "" |
| 493 |
"Never call B<read>(2), B<recv>(2), B<write>(2), or B<send>(2) with a buffer " |
| 494 |
"length of zero." |
| 495 |
msgstr "" |
| 496 |
"Никогда не вызывайте B<read>(2), B<recv>(2), B<write>(2) или B<send>(2) с " |
| 497 |
"буфером нулевой длины." |
| 498 |
|
| 499 |
#. type: TP |
| 500 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 501 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 502 |
#, no-wrap |
| 503 |
msgid "9." |
| 504 |
msgstr "9." |
| 505 |
|
| 506 |
#. type: Plain text |
| 507 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 508 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 509 |
msgid "" |
| 510 |
"If the functions B<read>(2), B<recv>(2), B<write>(2), and B<send>(2) fail " |
| 511 |
"with errors other than those listed in B<7.>, or one of the input functions " |
| 512 |
"returns 0, indicating end of file, then you should I<not> pass that file " |
| 513 |
"descriptor to B<select>() again. In the example below, I close the file " |
| 514 |
"descriptor immediately, and then set it to -1 to prevent it being included " |
| 515 |
"in a set." |
| 516 |
msgstr "" |
| 517 |
"Если вызовы B<read>(2), B<recv>(2), B<write>(2) и B<send>(2) завершаются с " |
| 518 |
"ошибками, отличными от перечисленных в пункте B<7.> или один из вызовов " |
| 519 |
"ввода вернул 0, что указывает на конец файла, то вы I<не> должны передавать " |
| 520 |
"этот файловый дескриптор в B<select>() снова. В примере выше я немедленно " |
| 521 |
"закрываю файловый дескриптор и устанавливаю его в -1 для предотвращения его " |
| 522 |
"включения в набор." |
| 523 |
|
| 524 |
#. type: TP |
| 525 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 526 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 527 |
#, no-wrap |
| 528 |
msgid "10." |
| 529 |
msgstr "10." |
| 530 |
|
| 531 |
#. type: Plain text |
| 532 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 533 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 534 |
msgid "" |
| 535 |
"The timeout value must be initialized with each new call to B<select>(), " |
| 536 |
"since some operating systems modify the structure. B<pselect>() however " |
| 537 |
"does not modify its timeout structure." |
| 538 |
msgstr "" |
| 539 |
"Значение времени ожидания должно быть инициализировано при каждом новом " |
| 540 |
"вызове B<select>(), так как некоторые операционные системы изменяют значение " |
| 541 |
"структуры. Однако B<pselect>() не изменяет структуру времени ожидания." |
| 542 |
|
| 543 |
#. type: TP |
| 544 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 545 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 546 |
#, no-wrap |
| 547 |
msgid "11." |
| 548 |
msgstr "11." |
| 549 |
|
| 550 |
#. "I have heard" does not fill me with confidence, and doesn't |
| 551 |
#. belong in a man page, so I've commented this point out. |
| 552 |
#. .TP |
| 553 |
#. 11. |
| 554 |
#. I have heard that the Windows socket layer does not cope with OOB data |
| 555 |
#. properly. |
| 556 |
#. It also does not cope with |
| 557 |
#. .BR select () |
| 558 |
#. calls when no file descriptors are set at all. |
| 559 |
#. Having no file descriptors set is a useful |
| 560 |
#. way to sleep the process with subsecond precision by using the timeout. |
| 561 |
#. (See further on.) |
| 562 |
#. type: Plain text |
| 563 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 564 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 565 |
msgid "" |
| 566 |
"Since B<select>() modifies its file descriptor sets, if the call is being " |
| 567 |
"used in a loop, then the sets must be reinitialized before each call." |
| 568 |
msgstr "" |
| 569 |
"Так как B<select>() изменяет переданные наборы файловых дескрипторов, то при " |
| 570 |
"использовании его в цикле наборы должны повторно инициализироваться перед " |
| 571 |
"каждым вызовом." |
| 572 |
|
| 573 |
#. type: SH |
| 574 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 575 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 576 |
#, no-wrap |
| 577 |
msgid "RETURN VALUE" |
| 578 |
msgstr "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" |
| 579 |
|
| 580 |
#. type: Plain text |
| 581 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 582 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 583 |
msgid "See B<select>(2)." |
| 584 |
msgstr "Смотрите B<select>(2)." |
| 585 |
|
| 586 |
#. type: SH |
| 587 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 588 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 589 |
#, no-wrap |
| 590 |
msgid "NOTES" |
| 591 |
msgstr "ПРИМЕЧАНИЯ" |
| 592 |
|
| 593 |
#. type: Plain text |
| 594 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 595 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 596 |
msgid "" |
| 597 |
"Generally speaking, all operating systems that support sockets also support " |
| 598 |
"B<select>(). B<select>() can be used to solve many problems in a portable " |
| 599 |
"and efficient way that naive programmers try to solve in a more complicated " |
| 600 |
"manner using threads, forking, IPCs, signals, memory sharing, and so on." |
| 601 |
msgstr "" |
| 602 |
"В общем случае, все операционные системы, поддерживающие сокеты, " |
| 603 |
"поддерживают также и B<select>(). Вызов B<select>() можно применять для " |
| 604 |
"переносимого и эффективного решения многих задач, вместо которого многие " |
| 605 |
"программисты пытаются использовать нити, ветвление процессов, IPC, сигналы, " |
| 606 |
"разделение памяти и другие методы." |
| 607 |
|
| 608 |
#. type: Plain text |
| 609 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 610 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 611 |
msgid "" |
| 612 |
"The B<poll>(2) system call has the same functionality as B<select>(), and " |
| 613 |
"is somewhat more efficient when monitoring sparse file descriptor sets. It " |
| 614 |
"is nowadays widely available, but historically was less portable than " |
| 615 |
"B<select>()." |
| 616 |
msgstr "" |
| 617 |
"Системный вызов B<poll>(2) имеет такую же функциональность, как и " |
| 618 |
"B<select>() и иногда более эффективен для слежения за разреженным набором " |
| 619 |
"файловых дескрипторов. В настоящее время он стал широко распространён, но " |
| 620 |
"исторически является менее переносимым чем B<select>()." |
| 621 |
|
| 622 |
#. type: Plain text |
| 623 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 624 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 625 |
msgid "" |
| 626 |
"The Linux-specific B<epoll>(7) API provides an interface that is more " |
| 627 |
"efficient than B<select>(2) and B<poll>(2) when monitoring large numbers " |
| 628 |
"of file descriptors." |
| 629 |
msgstr "" |
| 630 |
"Программный интерфейс Linux B<epoll>(7) предоставляет более эффективный " |
| 631 |
"метод для слежения за большим количеством файловых дескрипторов чем " |
| 632 |
"B<select>(2) и B<poll>(2)." |
| 633 |
|
| 634 |
#. type: SH |
| 635 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 636 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 637 |
#, no-wrap |
| 638 |
msgid "EXAMPLES" |
| 639 |
msgstr "ПРИМЕРЫ" |
| 640 |
|
| 641 |
#. type: Plain text |
| 642 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 643 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 644 |
msgid "" |
| 645 |
"Here is an example that better demonstrates the true utility of " |
| 646 |
"B<select>(). The listing below is a TCP forwarding program that forwards " |
| 647 |
"from one TCP port to another." |
| 648 |
msgstr "" |
| 649 |
"Вот пример, который лучше демонстрирует возможности B<select>(). Программа " |
| 650 |
"осуществляет перенаправление одного порта TCP в другой. " |
| 651 |
|
| 652 |
#. type: Plain text |
| 653 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 654 |
#: opensuse-tumbleweed |
| 655 |
#, no-wrap |
| 656 |
msgid "" |
| 657 |
"#include E<lt>arpa/inet.hE<gt>\n" |
| 658 |
"#include E<lt>errno.hE<gt>\n" |
| 659 |
"#include E<lt>netinet/in.hE<gt>\n" |
| 660 |
"#include E<lt>signal.hE<gt>\n" |
| 661 |
"#include E<lt>stdio.hE<gt>\n" |
| 662 |
"#include E<lt>stdlib.hE<gt>\n" |
| 663 |
"#include E<lt>string.hE<gt>\n" |
| 664 |
"#include E<lt>sys/select.hE<gt>\n" |
| 665 |
"#include E<lt>sys/socket.hE<gt>\n" |
| 666 |
"#include E<lt>sys/types.hE<gt>\n" |
| 667 |
"#include E<lt>unistd.hE<gt>\n" |
| 668 |
"\\&\n" |
| 669 |
"static int forward_port;\n" |
| 670 |
"\\&\n" |
| 671 |
"#undef max\n" |
| 672 |
"#define max(x, y) ((x) E<gt> (y) ? (x) : (y))\n" |
| 673 |
"\\&\n" |
| 674 |
"static int\n" |
| 675 |
"listen_socket(int listen_port)\n" |
| 676 |
"{\n" |
| 677 |
" int lfd;\n" |
| 678 |
" int yes;\n" |
| 679 |
" struct sockaddr_in addr;\n" |
| 680 |
"\\&\n" |
| 681 |
" lfd = socket(AF_INET, SOCK_STREAM, 0);\n" |
| 682 |
" if (lfd == -1) {\n" |
| 683 |
" perror(\"socket\");\n" |
| 684 |
" return -1;\n" |
| 685 |
" }\n" |
| 686 |
"\\&\n" |
| 687 |
" yes = 1;\n" |
| 688 |
" if (setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR,\n" |
| 689 |
" &yes, sizeof(yes)) == -1)\n" |
| 690 |
" {\n" |
| 691 |
" perror(\"setsockopt\");\n" |
| 692 |
" close(lfd);\n" |
| 693 |
" return -1;\n" |
| 694 |
" }\n" |
| 695 |
"\\&\n" |
| 696 |
" memset(&addr, 0, sizeof(addr));\n" |
| 697 |
" addr.sin_port = htons(listen_port);\n" |
| 698 |
" addr.sin_family = AF_INET;\n" |
| 699 |
" if (bind(lfd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {\n" |
| 700 |
" perror(\"bind\");\n" |
| 701 |
" close(lfd);\n" |
| 702 |
" return -1;\n" |
| 703 |
" }\n" |
| 704 |
"\\&\n" |
| 705 |
" printf(\"accepting connections on port %d\\[rs]n\", listen_port);\n" |
| 706 |
" listen(lfd, 10);\n" |
| 707 |
" return lfd;\n" |
| 708 |
"}\n" |
| 709 |
"\\&\n" |
| 710 |
"static int\n" |
| 711 |
"connect_socket(int connect_port, char *address)\n" |
| 712 |
"{\n" |
| 713 |
" int cfd;\n" |
| 714 |
" struct sockaddr_in addr;\n" |
| 715 |
"\\&\n" |
| 716 |
" cfd = socket(AF_INET, SOCK_STREAM, 0);\n" |
| 717 |
" if (cfd == -1) {\n" |
| 718 |
" perror(\"socket\");\n" |
| 719 |
" return -1;\n" |
| 720 |
" }\n" |
| 721 |
"\\&\n" |
| 722 |
" memset(&addr, 0, sizeof(addr));\n" |
| 723 |
" addr.sin_port = htons(connect_port);\n" |
| 724 |
" addr.sin_family = AF_INET;\n" |
| 725 |
"\\&\n" |
| 726 |
" if (!inet_aton(address, (struct in_addr *) &addr.sin_addr.s_addr)) {\n" |
| 727 |
" fprintf(stderr, \"inet_aton(): bad IP address format\\[rs]n\");\n" |
| 728 |
" close(cfd);\n" |
| 729 |
" return -1;\n" |
| 730 |
" }\n" |
| 731 |
"\\&\n" |
| 732 |
" if (connect(cfd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {\n" |
| 733 |
" perror(\"connect()\");\n" |
| 734 |
" shutdown(cfd, SHUT_RDWR);\n" |
| 735 |
" close(cfd);\n" |
| 736 |
" return -1;\n" |
| 737 |
" }\n" |
| 738 |
" return cfd;\n" |
| 739 |
"}\n" |
| 740 |
"\\&\n" |
| 741 |
"#define SHUT_FD1 do { \\[rs]\n" |
| 742 |
" if (fd1 E<gt>= 0) { \\[rs]\n" |
| 743 |
" shutdown(fd1, SHUT_RDWR); \\[rs]\n" |
| 744 |
" close(fd1); \\[rs]\n" |
| 745 |
" fd1 = -1; \\[rs]\n" |
| 746 |
" } \\[rs]\n" |
| 747 |
" } while (0)\n" |
| 748 |
"\\&\n" |
| 749 |
"#define SHUT_FD2 do { \\[rs]\n" |
| 750 |
" if (fd2 E<gt>= 0) { \\[rs]\n" |
| 751 |
" shutdown(fd2, SHUT_RDWR); \\[rs]\n" |
| 752 |
" close(fd2); \\[rs]\n" |
| 753 |
" fd2 = -1; \\[rs]\n" |
| 754 |
" } \\[rs]\n" |
| 755 |
" } while (0)\n" |
| 756 |
"\\&\n" |
| 757 |
"#define BUF_SIZE 1024\n" |
| 758 |
"\\&\n" |
| 759 |
"int\n" |
| 760 |
"main(int argc, char *argv[])\n" |
| 761 |
"{\n" |
| 762 |
" int h;\n" |
| 763 |
" int ready, nfds;\n" |
| 764 |
" int fd1 = -1, fd2 = -1;\n" |
| 765 |
" int buf1_avail = 0, buf1_written = 0;\n" |
| 766 |
" int buf2_avail = 0, buf2_written = 0;\n" |
| 767 |
" char buf1[BUF_SIZE], buf2[BUF_SIZE];\n" |
| 768 |
" fd_set readfds, writefds, exceptfds;\n" |
| 769 |
" ssize_t nbytes;\n" |
| 770 |
"\\&\n" |
| 771 |
" if (argc != 4) {\n" |
| 772 |
" fprintf(stderr, \"Usage\\[rs]n\\[rs]tfwd E<lt>listen-portE<gt> \"\n" |
| 773 |
" \"E<lt>forward-to-portE<gt> E<lt>forward-to-ip-addressE<gt>\\[rs]n\");\n" |
| 774 |
" exit(EXIT_FAILURE);\n" |
| 775 |
" }\n" |
| 776 |
"\\&\n" |
| 777 |
" signal(SIGPIPE, SIG_IGN);\n" |
| 778 |
"\\&\n" |
| 779 |
" forward_port = atoi(argv[2]);\n" |
| 780 |
"\\&\n" |
| 781 |
" h = listen_socket(atoi(argv[1]));\n" |
| 782 |
" if (h == -1)\n" |
| 783 |
" exit(EXIT_FAILURE);\n" |
| 784 |
"\\&\n" |
| 785 |
" for (;;) {\n" |
| 786 |
" nfds = 0;\n" |
| 787 |
"\\&\n" |
| 788 |
" FD_ZERO(&readfds);\n" |
| 789 |
" FD_ZERO(&writefds);\n" |
| 790 |
" FD_ZERO(&exceptfds);\n" |
| 791 |
" FD_SET(h, &readfds);\n" |
| 792 |
" nfds = max(nfds, h);\n" |
| 793 |
"\\&\n" |
| 794 |
" if (fd1 E<gt> 0 && buf1_avail E<lt> BUF_SIZE)\n" |
| 795 |
" FD_SET(fd1, &readfds);\n" |
| 796 |
" /* Note: nfds is updated below, when fd1 is added to\n" |
| 797 |
" exceptfds. */\n" |
| 798 |
" if (fd2 E<gt> 0 && buf2_avail E<lt> BUF_SIZE)\n" |
| 799 |
" FD_SET(fd2, &readfds);\n" |
| 800 |
"\\&\n" |
| 801 |
" if (fd1 E<gt> 0 && buf2_avail - buf2_written E<gt> 0)\n" |
| 802 |
" FD_SET(fd1, &writefds);\n" |
| 803 |
" if (fd2 E<gt> 0 && buf1_avail - buf1_written E<gt> 0)\n" |
| 804 |
" FD_SET(fd2, &writefds);\n" |
| 805 |
"\\&\n" |
| 806 |
" if (fd1 E<gt> 0) {\n" |
| 807 |
" FD_SET(fd1, &exceptfds);\n" |
| 808 |
" nfds = max(nfds, fd1);\n" |
| 809 |
" }\n" |
| 810 |
" if (fd2 E<gt> 0) {\n" |
| 811 |
" FD_SET(fd2, &exceptfds);\n" |
| 812 |
" nfds = max(nfds, fd2);\n" |
| 813 |
" }\n" |
| 814 |
"\\&\n" |
| 815 |
" ready = select(nfds + 1, &readfds, &writefds, &exceptfds, NULL);\n" |
| 816 |
"\\&\n" |
| 817 |
" if (ready == -1 && errno == EINTR)\n" |
| 818 |
" continue;\n" |
| 819 |
"\\&\n" |
| 820 |
" if (ready == -1) {\n" |
| 821 |
" perror(\"select()\");\n" |
| 822 |
" exit(EXIT_FAILURE);\n" |
| 823 |
" }\n" |
| 824 |
"\\&\n" |
| 825 |
" if (FD_ISSET(h, &readfds)) {\n" |
| 826 |
" socklen_t addrlen;\n" |
| 827 |
" struct sockaddr_in client_addr;\n" |
| 828 |
" int fd;\n" |
| 829 |
"\\&\n" |
| 830 |
" addrlen = sizeof(client_addr);\n" |
| 831 |
" memset(&client_addr, 0, addrlen);\n" |
| 832 |
" fd = accept(h, (struct sockaddr *) &client_addr, &addrlen);\n" |
| 833 |
" if (fd == -1) {\n" |
| 834 |
" perror(\"accept()\");\n" |
| 835 |
" } else {\n" |
| 836 |
" SHUT_FD1;\n" |
| 837 |
" SHUT_FD2;\n" |
| 838 |
" buf1_avail = buf1_written = 0;\n" |
| 839 |
" buf2_avail = buf2_written = 0;\n" |
| 840 |
" fd1 = fd;\n" |
| 841 |
" fd2 = connect_socket(forward_port, argv[3]);\n" |
| 842 |
" if (fd2 == -1)\n" |
| 843 |
" SHUT_FD1;\n" |
| 844 |
" else\n" |
| 845 |
" printf(\"connect from %s\\[rs]n\",\n" |
| 846 |
" inet_ntoa(client_addr.sin_addr));\n" |
| 847 |
"\\&\n" |
| 848 |
" /* Skip any events on the old, closed file\n" |
| 849 |
" descriptors. */\n" |
| 850 |
"\\&\n" |
| 851 |
" continue;\n" |
| 852 |
" }\n" |
| 853 |
" }\n" |
| 854 |
"\\&\n" |
| 855 |
" /* NB: read OOB data before normal reads. */\n" |
| 856 |
"\\&\n" |
| 857 |
" if (fd1 E<gt> 0 && FD_ISSET(fd1, &exceptfds)) {\n" |
| 858 |
" char c;\n" |
| 859 |
"\\&\n" |
| 860 |
" nbytes = recv(fd1, &c, 1, MSG_OOB);\n" |
| 861 |
" if (nbytes E<lt> 1)\n" |
| 862 |
" SHUT_FD1;\n" |
| 863 |
" else\n" |
| 864 |
" send(fd2, &c, 1, MSG_OOB);\n" |
| 865 |
" }\n" |
| 866 |
" if (fd2 E<gt> 0 && FD_ISSET(fd2, &exceptfds)) {\n" |
| 867 |
" char c;\n" |
| 868 |
"\\&\n" |
| 869 |
" nbytes = recv(fd2, &c, 1, MSG_OOB);\n" |
| 870 |
" if (nbytes E<lt> 1)\n" |
| 871 |
" SHUT_FD2;\n" |
| 872 |
" else\n" |
| 873 |
" send(fd1, &c, 1, MSG_OOB);\n" |
| 874 |
" }\n" |
| 875 |
" if (fd1 E<gt> 0 && FD_ISSET(fd1, &readfds)) {\n" |
| 876 |
" nbytes = read(fd1, buf1 + buf1_avail,\n" |
| 877 |
" BUF_SIZE - buf1_avail);\n" |
| 878 |
" if (nbytes E<lt> 1)\n" |
| 879 |
" SHUT_FD1;\n" |
| 880 |
" else\n" |
| 881 |
" buf1_avail += nbytes;\n" |
| 882 |
" }\n" |
| 883 |
" if (fd2 E<gt> 0 && FD_ISSET(fd2, &readfds)) {\n" |
| 884 |
" nbytes = read(fd2, buf2 + buf2_avail,\n" |
| 885 |
" BUF_SIZE - buf2_avail);\n" |
| 886 |
" if (nbytes E<lt> 1)\n" |
| 887 |
" SHUT_FD2;\n" |
| 888 |
" else\n" |
| 889 |
" buf2_avail += nbytes;\n" |
| 890 |
" }\n" |
| 891 |
" if (fd1 E<gt> 0 && FD_ISSET(fd1, &writefds) && buf2_avail E<gt> 0) {\n" |
| 892 |
" nbytes = write(fd1, buf2 + buf2_written,\n" |
| 893 |
" buf2_avail - buf2_written);\n" |
| 894 |
" if (nbytes E<lt> 1)\n" |
| 895 |
" SHUT_FD1;\n" |
| 896 |
" else\n" |
| 897 |
" buf2_written += nbytes;\n" |
| 898 |
" }\n" |
| 899 |
" if (fd2 E<gt> 0 && FD_ISSET(fd2, &writefds) && buf1_avail E<gt> 0) {\n" |
| 900 |
" nbytes = write(fd2, buf1 + buf1_written,\n" |
| 901 |
" buf1_avail - buf1_written);\n" |
| 902 |
" if (nbytes E<lt> 1)\n" |
| 903 |
" SHUT_FD2;\n" |
| 904 |
" else\n" |
| 905 |
" buf1_written += nbytes;\n" |
| 906 |
" }\n" |
| 907 |
"\\&\n" |
| 908 |
" /* Check if write data has caught read data. */\n" |
| 909 |
"\\&\n" |
| 910 |
" if (buf1_written == buf1_avail)\n" |
| 911 |
" buf1_written = buf1_avail = 0;\n" |
| 912 |
" if (buf2_written == buf2_avail)\n" |
| 913 |
" buf2_written = buf2_avail = 0;\n" |
| 914 |
"\\&\n" |
| 915 |
" /* One side has closed the connection, keep\n" |
| 916 |
" writing to the other side until empty. */\n" |
| 917 |
"\\&\n" |
| 918 |
" if (fd1 E<lt> 0 && buf1_avail - buf1_written == 0)\n" |
| 919 |
" SHUT_FD2;\n" |
| 920 |
" if (fd2 E<lt> 0 && buf2_avail - buf2_written == 0)\n" |
| 921 |
" SHUT_FD1;\n" |
| 922 |
" }\n" |
| 923 |
" exit(EXIT_SUCCESS);\n" |
| 924 |
"}\n" |
| 925 |
msgstr "" |
| 926 |
|
| 927 |
#. type: Plain text |
| 928 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 929 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 930 |
msgid "" |
| 931 |
"The above program properly forwards most kinds of TCP connections including " |
| 932 |
"OOB signal data transmitted by B<telnet> servers. It handles the tricky " |
| 933 |
"problem of having data flow in both directions simultaneously. You might " |
| 934 |
"think it more efficient to use a B<fork>(2) call and devote a thread to " |
| 935 |
"each stream. This becomes more tricky than you might suspect. Another idea " |
| 936 |
"is to set nonblocking I/O using B<fcntl>(2). This also has its problems " |
| 937 |
"because you end up using inefficient timeouts." |
| 938 |
msgstr "" |
| 939 |
"Вышеприведенная программа правильно перенаправляет большинство данных задач, " |
| 940 |
"использующих соединения TCP, включая внепоточные (OOB) данные, передаваемые " |
| 941 |
"серверами B<telnet>. Она справляется со сложной проблемой поддержания " |
| 942 |
"одновременного двустороннего обмена данными. Возможно, вы решите, что " |
| 943 |
"эффективнее использовать B<fork>(2) и выделить отдельную нить для каждого " |
| 944 |
"потока. На самом деле это сложнее, чем кажется. Другой идеей может быть " |
| 945 |
"использование неблокирующего ввода-вывода с помощью B<fcntl>(2). Это также " |
| 946 |
"может вызвать проблемы из-за того, что придётся использовать неэффективные " |
| 947 |
"таймауты." |
| 948 |
|
| 949 |
#. type: Plain text |
| 950 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 951 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 952 |
#, fuzzy |
| 953 |
#| msgid "" |
| 954 |
#| "The program does not handle more than one simultaneous connection at a " |
| 955 |
#| "time, although it could easily be extended to do this with a linked list " |
| 956 |
#| "of buffers\\(emone for each connection. At the moment, new connections " |
| 957 |
#| "cause the current connection to be dropped." |
| 958 |
msgid "" |
| 959 |
"The program does not handle more than one simultaneous connection at a time, " |
| 960 |
"although it could easily be extended to do this with a linked list of " |
| 961 |
"buffers\\[em]one for each connection. At the moment, new connections cause " |
| 962 |
"the current connection to be dropped." |
| 963 |
msgstr "" |
| 964 |
"Программа не обрабатывает более одного соединения, однако она может быть " |
| 965 |
"легко доработана путем добавления связанного списка буферов — по одному на " |
| 966 |
"каждое соединение. В данный момент новые соединения приводят к закрытию " |
| 967 |
"текущего." |
| 968 |
|
| 969 |
#. type: SH |
| 970 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 971 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 972 |
#, no-wrap |
| 973 |
msgid "SEE ALSO" |
| 974 |
msgstr "СМОТРИТЕ ТАКЖЕ" |
| 975 |
|
| 976 |
#. type: Plain text |
| 977 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 978 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 979 |
msgid "" |
| 980 |
"B<accept>(2), B<connect>(2), B<poll>(2), B<read>(2), B<recv>(2), " |
| 981 |
"B<select>(2), B<send>(2), B<sigprocmask>(2), B<write>(2), B<epoll>(7)" |
| 982 |
msgstr "" |
| 983 |
"B<accept>(2), B<connect>(2), B<poll>(2), B<read>(2), B<recv>(2), " |
| 984 |
"B<select>(2), B<send>(2), B<sigprocmask>(2), B<write>(2), B<epoll>(7)" |
| 985 |
|
| 986 |
#. type: TH |
| 987 |
#: debian-trixie |
| 988 |
#, no-wrap |
| 989 |
msgid "2024-06-15" |
| 990 |
msgstr "15 июня 2024 г." |
| 991 |
|
| 992 |
#. type: TH |
| 993 |
#: debian-trixie |
| 994 |
#, no-wrap |
| 995 |
msgid "Linux man-pages 6.9.1" |
| 996 |
msgstr "Страницы руководства Linux 6.9.1" |
| 997 |
|
| 998 |
#. type: Plain text |
| 999 |
#: debian-trixie |
| 1000 |
msgid "Standard C library (I<libc>, I<-lc>)" |
| 1001 |
msgstr "Стандартная библиотека языка C (I<libc>, I<-lc>)" |
| 1002 |
|
| 1003 |
#. type: Plain text |
| 1004 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1005 |
#, no-wrap |
| 1006 |
msgid "" |
| 1007 |
"static volatile sig_atomic_t got_SIGCHLD = 0;\n" |
| 1008 |
"\\&\n" |
| 1009 |
"static void\n" |
| 1010 |
"child_sig_handler(int sig)\n" |
| 1011 |
"{\n" |
| 1012 |
" got_SIGCHLD = 1;\n" |
| 1013 |
"}\n" |
| 1014 |
"\\&\n" |
| 1015 |
"int\n" |
| 1016 |
"main(int argc, char *argv[])\n" |
| 1017 |
"{\n" |
| 1018 |
" sigset_t sigmask, empty_mask;\n" |
| 1019 |
" struct sigaction sa;\n" |
| 1020 |
" fd_set readfds, writefds, exceptfds;\n" |
| 1021 |
" int r;\n" |
| 1022 |
"\\&\n" |
| 1023 |
" sigemptyset(&sigmask);\n" |
| 1024 |
" sigaddset(&sigmask, SIGCHLD);\n" |
| 1025 |
" if (sigprocmask(SIG_BLOCK, &sigmask, NULL) == -1) {\n" |
| 1026 |
" perror(\"sigprocmask\");\n" |
| 1027 |
" exit(EXIT_FAILURE);\n" |
| 1028 |
" }\n" |
| 1029 |
"\\&\n" |
| 1030 |
" sa.sa_flags = 0;\n" |
| 1031 |
" sa.sa_handler = child_sig_handler;\n" |
| 1032 |
" sigemptyset(&sa.sa_mask);\n" |
| 1033 |
" if (sigaction(SIGCHLD, &sa, NULL) == -1) {\n" |
| 1034 |
" perror(\"sigaction\");\n" |
| 1035 |
" exit(EXIT_FAILURE);\n" |
| 1036 |
" }\n" |
| 1037 |
"\\&\n" |
| 1038 |
" sigemptyset(&empty_mask);\n" |
| 1039 |
"\\&\n" |
| 1040 |
" for (;;) { /* main loop */\n" |
| 1041 |
" /* Initialize readfds, writefds, and exceptfds\n" |
| 1042 |
" before the pselect() call. (Code omitted.) */\n" |
| 1043 |
"\\&\n" |
| 1044 |
" r = pselect(nfds, &readfds, &writefds, &exceptfds,\n" |
| 1045 |
" NULL, &empty_mask);\n" |
| 1046 |
" if (r == -1 && errno != EINTR) {\n" |
| 1047 |
" /* Handle error */\n" |
| 1048 |
" }\n" |
| 1049 |
"\\&\n" |
| 1050 |
" if (got_SIGCHLD) {\n" |
| 1051 |
" got_SIGCHLD = 0;\n" |
| 1052 |
"\\&\n" |
| 1053 |
" /* Handle signalled event here; e.g., wait() for all\n" |
| 1054 |
" terminated children. (Code omitted.) */\n" |
| 1055 |
" }\n" |
| 1056 |
"\\&\n" |
| 1057 |
" /* main body of program */\n" |
| 1058 |
" }\n" |
| 1059 |
"}\n" |
| 1060 |
msgstr "" |
| 1061 |
|
| 1062 |
#. type: Plain text |
| 1063 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1064 |
#, no-wrap |
| 1065 |
msgid "" |
| 1066 |
"#include E<lt>arpa/inet.hE<gt>\n" |
| 1067 |
"#include E<lt>errno.hE<gt>\n" |
| 1068 |
"#include E<lt>netinet/in.hE<gt>\n" |
| 1069 |
"#include E<lt>signal.hE<gt>\n" |
| 1070 |
"#include E<lt>stdio.hE<gt>\n" |
| 1071 |
"#include E<lt>stdlib.hE<gt>\n" |
| 1072 |
"#include E<lt>string.hE<gt>\n" |
| 1073 |
"#include E<lt>sys/select.hE<gt>\n" |
| 1074 |
"#include E<lt>sys/socket.hE<gt>\n" |
| 1075 |
"#include E<lt>sys/types.hE<gt>\n" |
| 1076 |
"#include E<lt>unistd.hE<gt>\n" |
| 1077 |
"\\&\n" |
| 1078 |
"static int forward_port;\n" |
| 1079 |
"\\&\n" |
| 1080 |
"#undef max\n" |
| 1081 |
"#define max(x, y) ((x) E<gt> (y) ? (x) : (y))\n" |
| 1082 |
"\\&\n" |
| 1083 |
"static int\n" |
| 1084 |
"listen_socket(int listen_port)\n" |
| 1085 |
"{\n" |
| 1086 |
" int lfd;\n" |
| 1087 |
" int yes;\n" |
| 1088 |
" struct sockaddr_in addr;\n" |
| 1089 |
"\\&\n" |
| 1090 |
" lfd = socket(AF_INET, SOCK_STREAM, 0);\n" |
| 1091 |
" if (lfd == -1) {\n" |
| 1092 |
" perror(\"socket\");\n" |
| 1093 |
" return -1;\n" |
| 1094 |
" }\n" |
| 1095 |
"\\&\n" |
| 1096 |
" yes = 1;\n" |
| 1097 |
" if (setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR,\n" |
| 1098 |
" &yes, sizeof(yes)) == -1)\n" |
| 1099 |
" {\n" |
| 1100 |
" perror(\"setsockopt\");\n" |
| 1101 |
" close(lfd);\n" |
| 1102 |
" return -1;\n" |
| 1103 |
" }\n" |
| 1104 |
"\\&\n" |
| 1105 |
" memset(&addr, 0, sizeof(addr));\n" |
| 1106 |
" addr.sin_port = htons(listen_port);\n" |
| 1107 |
" addr.sin_family = AF_INET;\n" |
| 1108 |
" if (bind(lfd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {\n" |
| 1109 |
" perror(\"bind\");\n" |
| 1110 |
" close(lfd);\n" |
| 1111 |
" return -1;\n" |
| 1112 |
" }\n" |
| 1113 |
"\\&\n" |
| 1114 |
" printf(\"accepting connections on port %d\\[rs]n\", listen_port);\n" |
| 1115 |
" listen(lfd, 10);\n" |
| 1116 |
" return lfd;\n" |
| 1117 |
"}\n" |
| 1118 |
"\\&\n" |
| 1119 |
"static int\n" |
| 1120 |
"connect_socket(int connect_port, char *address)\n" |
| 1121 |
"{\n" |
| 1122 |
" int cfd;\n" |
| 1123 |
" struct sockaddr_in addr;\n" |
| 1124 |
"\\&\n" |
| 1125 |
" cfd = socket(AF_INET, SOCK_STREAM, 0);\n" |
| 1126 |
" if (cfd == -1) {\n" |
| 1127 |
" perror(\"socket\");\n" |
| 1128 |
" return -1;\n" |
| 1129 |
" }\n" |
| 1130 |
"\\&\n" |
| 1131 |
" memset(&addr, 0, sizeof(addr));\n" |
| 1132 |
" addr.sin_port = htons(connect_port);\n" |
| 1133 |
" addr.sin_family = AF_INET;\n" |
| 1134 |
"\\&\n" |
| 1135 |
" if (!inet_aton(address, (struct in_addr *) &addr.sin_addr.s_addr)) {\n" |
| 1136 |
" fprintf(stderr, \"inet_aton(): bad IP address format\\[rs]n\");\n" |
| 1137 |
" close(cfd);\n" |
| 1138 |
" return -1;\n" |
| 1139 |
" }\n" |
| 1140 |
"\\&\n" |
| 1141 |
" if (connect(cfd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {\n" |
| 1142 |
" perror(\"connect()\");\n" |
| 1143 |
" shutdown(cfd, SHUT_RDWR);\n" |
| 1144 |
" close(cfd);\n" |
| 1145 |
" return -1;\n" |
| 1146 |
" }\n" |
| 1147 |
" return cfd;\n" |
| 1148 |
"}\n" |
| 1149 |
"\\&\n" |
| 1150 |
"#define SHUT_FD1 do { \\[rs]\n" |
| 1151 |
" if (fd1 E<gt>= 0) { \\[rs]\n" |
| 1152 |
" shutdown(fd1, SHUT_RDWR); \\[rs]\n" |
| 1153 |
" close(fd1); \\[rs]\n" |
| 1154 |
" fd1 = -1; \\[rs]\n" |
| 1155 |
" } \\[rs]\n" |
| 1156 |
" } while (0)\n" |
| 1157 |
"\\&\n" |
| 1158 |
"#define SHUT_FD2 do { \\[rs]\n" |
| 1159 |
" if (fd2 E<gt>= 0) { \\[rs]\n" |
| 1160 |
" shutdown(fd2, SHUT_RDWR); \\[rs]\n" |
| 1161 |
" close(fd2); \\[rs]\n" |
| 1162 |
" fd2 = -1; \\[rs]\n" |
| 1163 |
" } \\[rs]\n" |
| 1164 |
" } while (0)\n" |
| 1165 |
"\\&\n" |
| 1166 |
"#define BUF_SIZE 1024\n" |
| 1167 |
"\\&\n" |
| 1168 |
"int\n" |
| 1169 |
"main(int argc, char *argv[])\n" |
| 1170 |
"{\n" |
| 1171 |
" int h;\n" |
| 1172 |
" int ready, nfds;\n" |
| 1173 |
" int fd1 = -1, fd2 = -1;\n" |
| 1174 |
" int buf1_avail = 0, buf1_written = 0;\n" |
| 1175 |
" int buf2_avail = 0, buf2_written = 0;\n" |
| 1176 |
" char buf1[BUF_SIZE], buf2[BUF_SIZE];\n" |
| 1177 |
" fd_set readfds, writefds, exceptfds;\n" |
| 1178 |
" ssize_t nbytes;\n" |
| 1179 |
"\\&\n" |
| 1180 |
" if (argc != 4) {\n" |
| 1181 |
" fprintf(stderr, \"Usage\\[rs]n\\[rs]tfwd E<lt>listen-portE<gt> \"\n" |
| 1182 |
" \"E<lt>forward-to-portE<gt> E<lt>forward-to-ip-addressE<gt>\\[rs]n\");\n" |
| 1183 |
" exit(EXIT_FAILURE);\n" |
| 1184 |
" }\n" |
| 1185 |
"\\&\n" |
| 1186 |
" signal(SIGPIPE, SIG_IGN);\n" |
| 1187 |
"\\&\n" |
| 1188 |
" forward_port = atoi(argv[2]);\n" |
| 1189 |
"\\&\n" |
| 1190 |
" h = listen_socket(atoi(argv[1]));\n" |
| 1191 |
" if (h == -1)\n" |
| 1192 |
" exit(EXIT_FAILURE);\n" |
| 1193 |
"\\&\n" |
| 1194 |
" for (;;) {\n" |
| 1195 |
" nfds = 0;\n" |
| 1196 |
"\\&\n" |
| 1197 |
" FD_ZERO(&readfds);\n" |
| 1198 |
" FD_ZERO(&writefds);\n" |
| 1199 |
" FD_ZERO(&exceptfds);\n" |
| 1200 |
" FD_SET(h, &readfds);\n" |
| 1201 |
" nfds = max(nfds, h);\n" |
| 1202 |
"\\&\n" |
| 1203 |
" if (fd1 E<gt> 0 && buf1_avail E<lt> BUF_SIZE)\n" |
| 1204 |
" FD_SET(fd1, &readfds);\n" |
| 1205 |
" /* Note: nfds is updated below, when fd1 is added to\n" |
| 1206 |
" exceptfds. */\n" |
| 1207 |
" if (fd2 E<gt> 0 && buf2_avail E<lt> BUF_SIZE)\n" |
| 1208 |
" FD_SET(fd2, &readfds);\n" |
| 1209 |
"\\&\n" |
| 1210 |
" if (fd1 E<gt> 0 && buf2_avail - buf2_written E<gt> 0)\n" |
| 1211 |
" FD_SET(fd1, &writefds);\n" |
| 1212 |
" if (fd2 E<gt> 0 && buf1_avail - buf1_written E<gt> 0)\n" |
| 1213 |
" FD_SET(fd2, &writefds);\n" |
| 1214 |
"\\&\n" |
| 1215 |
" if (fd1 E<gt> 0) {\n" |
| 1216 |
" FD_SET(fd1, &exceptfds);\n" |
| 1217 |
" nfds = max(nfds, fd1);\n" |
| 1218 |
" }\n" |
| 1219 |
" if (fd2 E<gt> 0) {\n" |
| 1220 |
" FD_SET(fd2, &exceptfds);\n" |
| 1221 |
" nfds = max(nfds, fd2);\n" |
| 1222 |
" }\n" |
| 1223 |
"\\&\n" |
| 1224 |
" ready = select(nfds + 1, &readfds, &writefds, &exceptfds, NULL);\n" |
| 1225 |
"\\&\n" |
| 1226 |
" if (ready == -1 && errno == EINTR)\n" |
| 1227 |
" continue;\n" |
| 1228 |
"\\&\n" |
| 1229 |
" if (ready == -1) {\n" |
| 1230 |
" perror(\"select()\");\n" |
| 1231 |
" exit(EXIT_FAILURE);\n" |
| 1232 |
" }\n" |
| 1233 |
"\\&\n" |
| 1234 |
" if (FD_ISSET(h, &readfds)) {\n" |
| 1235 |
" socklen_t addrlen;\n" |
| 1236 |
" struct sockaddr_in client_addr;\n" |
| 1237 |
" int fd;\n" |
| 1238 |
"\\&\n" |
| 1239 |
" addrlen = sizeof(client_addr);\n" |
| 1240 |
" memset(&client_addr, 0, addrlen);\n" |
| 1241 |
" fd = accept(h, (struct sockaddr *) &client_addr, &addrlen);\n" |
| 1242 |
" if (fd == -1) {\n" |
| 1243 |
" perror(\"accept()\");\n" |
| 1244 |
" } else {\n" |
| 1245 |
" SHUT_FD1;\n" |
| 1246 |
" SHUT_FD2;\n" |
| 1247 |
" buf1_avail = buf1_written = 0;\n" |
| 1248 |
" buf2_avail = buf2_written = 0;\n" |
| 1249 |
" fd1 = fd;\n" |
| 1250 |
" fd2 = connect_socket(forward_port, argv[3]);\n" |
| 1251 |
" if (fd2 == -1)\n" |
| 1252 |
" SHUT_FD1;\n" |
| 1253 |
" else\n" |
| 1254 |
" printf(\"connect from %s\\[rs]n\",\n" |
| 1255 |
" inet_ntoa(client_addr.sin_addr));\n" |
| 1256 |
"\\&\n" |
| 1257 |
" /* Skip any events on the old, closed file\n" |
| 1258 |
" descriptors. */\n" |
| 1259 |
"\\&\n" |
| 1260 |
" continue;\n" |
| 1261 |
" }\n" |
| 1262 |
" }\n" |
| 1263 |
"\\&\n" |
| 1264 |
" /* NB: read OOB data before normal reads. */\n" |
| 1265 |
"\\&\n" |
| 1266 |
" if (fd1 E<gt> 0 && FD_ISSET(fd1, &exceptfds)) {\n" |
| 1267 |
" char c;\n" |
| 1268 |
"\\&\n" |
| 1269 |
" nbytes = recv(fd1, &c, 1, MSG_OOB);\n" |
| 1270 |
" if (nbytes E<lt> 1)\n" |
| 1271 |
" SHUT_FD1;\n" |
| 1272 |
" else\n" |
| 1273 |
" send(fd2, &c, 1, MSG_OOB);\n" |
| 1274 |
" }\n" |
| 1275 |
" if (fd2 E<gt> 0 && FD_ISSET(fd2, &exceptfds)) {\n" |
| 1276 |
" char c;\n" |
| 1277 |
"\\&\n" |
| 1278 |
" nbytes = recv(fd2, &c, 1, MSG_OOB);\n" |
| 1279 |
" if (nbytes E<lt> 1)\n" |
| 1280 |
" SHUT_FD2;\n" |
| 1281 |
" else\n" |
| 1282 |
" send(fd1, &c, 1, MSG_OOB);\n" |
| 1283 |
" }\n" |
| 1284 |
" if (fd1 E<gt> 0 && FD_ISSET(fd1, &readfds)) {\n" |
| 1285 |
" nbytes = read(fd1, buf1 + buf1_avail,\n" |
| 1286 |
" BUF_SIZE - buf1_avail);\n" |
| 1287 |
" if (nbytes E<lt> 1)\n" |
| 1288 |
" SHUT_FD1;\n" |
| 1289 |
" else\n" |
| 1290 |
" buf1_avail += nbytes;\n" |
| 1291 |
" }\n" |
| 1292 |
" if (fd2 E<gt> 0 && FD_ISSET(fd2, &readfds)) {\n" |
| 1293 |
" nbytes = read(fd2, buf2 + buf2_avail,\n" |
| 1294 |
" BUF_SIZE - buf2_avail);\n" |
| 1295 |
" if (nbytes E<lt> 1)\n" |
| 1296 |
" SHUT_FD2;\n" |
| 1297 |
" else\n" |
| 1298 |
" buf2_avail += nbytes;\n" |
| 1299 |
" }\n" |
| 1300 |
" if (fd1 E<gt> 0 && FD_ISSET(fd1, &writefds) && buf2_avail E<gt> 0) {\n" |
| 1301 |
" nbytes = write(fd1, buf2 + buf2_written,\n" |
| 1302 |
" buf2_avail - buf2_written);\n" |
| 1303 |
" if (nbytes E<lt> 1)\n" |
| 1304 |
" SHUT_FD1;\n" |
| 1305 |
" else\n" |
| 1306 |
" buf2_written += nbytes;\n" |
| 1307 |
" }\n" |
| 1308 |
" if (fd2 E<gt> 0 && FD_ISSET(fd2, &writefds) && buf1_avail E<gt> 0) {\n" |
| 1309 |
" nbytes = write(fd2, buf1 + buf1_written,\n" |
| 1310 |
" buf1_avail - buf1_written);\n" |
| 1311 |
" if (nbytes E<lt> 1)\n" |
| 1312 |
" SHUT_FD2;\n" |
| 1313 |
" else\n" |
| 1314 |
" buf1_written += nbytes;\n" |
| 1315 |
" }\n" |
| 1316 |
"\\&\n" |
| 1317 |
" /* Check if write data has caught read data. */\n" |
| 1318 |
"\\&\n" |
| 1319 |
" if (buf1_written == buf1_avail)\n" |
| 1320 |
" buf1_written = buf1_avail = 0;\n" |
| 1321 |
" if (buf2_written == buf2_avail)\n" |
| 1322 |
" buf2_written = buf2_avail = 0;\n" |
| 1323 |
"\\&\n" |
| 1324 |
" /* One side has closed the connection, keep\n" |
| 1325 |
" writing to the other side until empty. */\n" |
| 1326 |
"\\&\n" |
| 1327 |
" if (fd1 E<lt> 0 && buf1_avail - buf1_written == 0)\n" |
| 1328 |
" SHUT_FD2;\n" |
| 1329 |
" if (fd2 E<lt> 0 && buf2_avail - buf2_written == 0)\n" |
| 1330 |
" SHUT_FD1;\n" |
| 1331 |
" }\n" |
| 1332 |
" exit(EXIT_SUCCESS);\n" |
| 1333 |
"}\n" |
| 1334 |
msgstr "" |
| 1335 |
|
| 1336 |
#. type: TH |
| 1337 |
#: fedora-44 fedora-rawhide |
| 1338 |
#, no-wrap |
| 1339 |
msgid "2024-07-23" |
| 1340 |
msgstr "23 июля 2024 г." |
| 1341 |
|
| 1342 |
#. type: TH |
| 1343 |
#: fedora-44 fedora-rawhide |
| 1344 |
#, no-wrap |
| 1345 |
msgid "Linux man-pages 6.13" |
| 1346 |
msgstr "Страницы руководства Linux 6.13" |
| 1347 |
|
| 1348 |
#. type: TH |
| 1349 |
#: mageia-cauldron |
| 1350 |
#, no-wrap |
| 1351 |
msgid "Linux man-pages 6.17" |
| 1352 |
msgstr "Страницы руководства Linux 6.17" |
| 1353 |
|
| 1354 |
#. type: TH |
| 1355 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 1356 |
#, no-wrap |
| 1357 |
msgid "Linux man-pages (unreleased)" |
| 1358 |
msgstr "Страницы руководства Linux (не выпущены)" |