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

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

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

解决方法

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

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

目前,这是您需要的,这些是从NetBSD手册页中获取的Posix选项. Linux上有更多可用的东西.在Linux上运行时,Ruby将定义其他符号,否则它们可能是未定义的,具体取决于主机. (谢谢,mark4o.)

  1. The flags argument to a recv call is formed by or'ing one or more of the
  2. values:
  3.  
  4. MSG_OOB process out-of-band data
  5. MSG_PEEK peek at incoming message
  6. MSG_WAITALL wait for full request or error
  7.  
  8. The MSG_OOB flag requests receipt of out-of-band data that would not be
  9. received in the normal data stream. Some protocols place expedited data
  10. at the head of the normal data queue,and thus this flag cannot be used
  11. with such protocols. The MSG_PEEK flag causes the receive operation to
  12. return data from the beginning of the receive queue without removing that
  13. data from the queue. Thus,a subsequent receive call will return the
  14. same data. The MSG_WAITALL flag requests that the operation block until
  15. the full request is satisfied. However,the call may still return less
  16. 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
  17. returned.

猜你在找的Ruby相关文章