Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在哪里为ruby套接字定义了MSG_uu选项?_Ruby_Sockets - Fatal编程技术网

在哪里为ruby套接字定义了MSG_uu选项?

在哪里为ruby套接字定义了MSG_uu选项?,ruby,sockets,Ruby,Sockets,在Ruby类Socket::recv的文档中,提到了第二个选项参数“flag”,它被称为零个或多个MSG_uu选项 我检查了几个不同的网站,没有找到MSG_uuu的选择。有人能给我指一下这些标志的文档吗?我几个月前就被这件事缠住了。首先,您使用的是“Socket”类,对吗?因为那就是我用的 我不确定,但这取决于您使用“Socket”类创建的协议 例如,如果将套接字创建为TCP套接字: sock = Socket.open(Socket::PF_INET, Socket::SOCK_RAW, So

在Ruby类Socket::recv的文档中,提到了第二个选项参数“flag”,它被称为零个或多个MSG_uu选项


我检查了几个不同的网站,没有找到MSG_uuu的选择。有人能给我指一下这些标志的文档吗?

我几个月前就被这件事缠住了。首先,您使用的是“Socket”类,对吗?因为那就是我用的

我不确定,但这取决于您使用“Socket”类创建的协议

例如,如果将套接字创建为TCP套接字:

sock = Socket.open(Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_RAW)
这些标志将是TCP协议的六个标志(URG、ACK、PSH等)


我不确定这一点,但0对我来说工作得很好。

它们与C BSD套接字堆栈中相应的
#define
s具有相同的名称,但前面的
套接字除外:
。(为了记录在案,为了回答您提出的确切问题,我应该在Ruby源代码树中说“in
ext/socket/socket.c
”)因此:

您可以通过键入
man2recv
看到这一点,尽管您可能需要先安装一个手册页软件包。还有联机手册页,请参阅:

现在,这里是您需要的,这些是从手册页获取的Posix选项。Linux上还有很多可用的功能。在Linux上运行时,Ruby将定义附加符号,否则根据主机的不同,这些符号可能未定义。(谢谢,)


其中很多都是特定于Linux的。POSIX仅包括MSG_PEEK、MSG_OOB和MSG_WAITALL。这是一个非常好的观点。但是,请注意,Ruby在Linux系统上运行时确实支持它们。如果您还包括send的POSIX标志,而不仅仅是recv,那么这个答案会更好。
>> require 'socket'
=> true
>> Socket::MSG_PEEK
=> 2
 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.