为ruby套接字定义的MSG_选项在哪里?

前端之家收集整理的这篇文章主要介绍了为ruby套接字定义的MSG_选项在哪里?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Ruby类Socket :: recv的文档中,提到了第二个选项参数“flag”,据说它是零个或多个MSG_选项.

我检查了几个不同的网站,但无法找到MSG_的选择.谁能指点我这些标志的文件

解决方法

它们与C BSD套接字堆栈中的相应#defines具有相同的名称,但前面的Socket ::除外. (为了记录,回答你问的确切问题,我应该在Ruby源代码树中说“在ext / socket / socket.c中”.)所以:
>> require 'socket'
=> true
>> Socket::MSG_PEEK
=> 2

你可以通过键入man 2 recv来看到这一点,尽管你可能需要先安装一个手册页包.还有在线手册页,请参见:man 2 recv here.

目前,这是您需要的,这些是从NetBSD手册页中获取的Posix选项. 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.
原文链接:https://www.f2er.com/ruby/269597.html

猜你在找的Ruby相关文章