Они имеют те же названия, что и соответствующие #define
s в стеке сокетов C BSD, за исключением Socket::
спереди. (А для записи, чтобы ответить на точный вопрос, который вы просили, я должен сказать, «в ext/socket/socket.c
» в исходном дереве Ruby.) Итак:
>> require 'socket'
=> true
>> Socket::MSG_PEEK
=> 2
Вы можете, вероятно, увидеть, набрав man 2 recv
, хоть ты может потребоваться сначала установить пакет страниц для man. Есть также онлайн-страницы руководства, см., Возможно: man 2 recv here.
На данный момент вот что вам нужно, это параметры Posix, взятые из справочной страницы NetBSD. В Linux гораздо больше доступно. При работе в Linux Ruby будет определять дополнительные символы, иначе они могут быть неопределенными в зависимости от хоста. (Спасибо, mark4o.)
The flags argument to a recv call is formed by or'ing one or more of the
values:
MSG_OOB process out-of-band data
MSG_PEEK peek at incoming message
MSG_WAITALL wait for full request or error
The MSG_OOB flag requests receipt of out-of-band data that would not be
received in the normal data stream. Some protocols place expedited data
at the head of the normal data queue, and thus this flag cannot be used
with such protocols. The MSG_PEEK flag causes the receive operation to
return data from the beginning of the receive queue without removing that
data from the queue. Thus, a subsequent receive call will return the
same data. The MSG_WAITALL flag requests that the operation block until
the full request is satisfied. However, the call may still return less
data than requested if a signal is caught, an error or disconnect occurs,
or the next data to be received is of a different type than that
returned.
Многие из них относятся к Linux. POSIX включает только MSG_PEEK, MSG_OOB и MSG_WAITALL. http://www.opengroup.org/onlinepubs/9699919799/functions/recv.html – mark4o
Это очень хороший момент. Однако обратите внимание, что Ruby поддерживает их при работе в системе Linux. – DigitalRoss
Этот ответ будет еще лучше, если вы также включили флаги POSIX для отправки, а не только recv. – Phrogz