1

I am struggling to implement the INSTREAM command of clamd daemon in Ruby. Here is the document of clamd

@file = File.open("input.txt")
socket = TCPSocket.new(HOST, PORT)
#writing the command
socket.write("zINSTREAM\0")
#streaming the chunk
socket.write(1024) #size of chunk
socket.write(@file.read(1024)) #chunk of data
#end the streaming
socket.write(0)
puts "Reading from the scoket"
puts socket.recv(1024)
socket.close

But I am always receiving the error response "INSTREAM size limit exceeded. ERROR" What I doing wrong here?

4

1 回答 1

3

经过长期的斗争,我找到了解决方案。

块的大小必须以网络字节顺序的 4 字节无符号整数表示

所以

socket.write(1024)

应该

socket.write([1024].pack("N"))
于 2012-09-24T21:24:10.297 回答