lib/fastdfs-client/socket.rb in fastdfs-client-1.3.0 vs lib/fastdfs-client/socket.rb in fastdfs-client-1.4.0
- old
+ new
@@ -5,11 +5,11 @@
module Fastdfs
module Client
class Socket
- attr_accessor :header, :content, :header_len, :cmd, :socket, :host, :port
+ attr_accessor :socket, :host, :port
def initialize(host, port, options = {})
@host, @port = host, port
@header_len = ProtoCommon::HEAD_LEN
@options = options || {}
@@ -17,11 +17,10 @@
@recv_timeout = @options[:recv_timeout] || 20
connection
end
def write(*args)
- debugger if args[1] == 119
@cmd = args.shift
pkg = args.shift
pkg = pkg.pack("C*") if pkg.is_a?(Array)
@socket.write pkg
@@ -58,12 +57,12 @@
end
private
def parseHeader
err_msg = nil
- err_msg = "recv package size #{@header} is not equal #{@header_len}, cmd: #{@cmd}" unless @header.length == @header_len || err_msg
- err_msg = "recv cmd: #{@header[8]} is not correct, expect recv code: #{CMD::RESP_CODE}, cmd: #{@cmd}" unless @header[8] == CMD::RESP_CODE || err_msg
- err_msg = "recv erron #{@header[9]}, 0 is correct cmd: #{@cmd}" unless @header[9] == 0 || err_msg
+ err_msg = "recv package size #{@header} is not equal #{@header_len}, cmd: #{CMD::MAPPING_NAME[@cmd]}" unless @header.length == @header_len || err_msg
+ err_msg = "recv cmd: #{@header[8]} is not correct, expect recv code: #{CMD::RESP_CODE}, cmd: #{CMD::MAPPING_NAME[@cmd]}" unless @header[8] == CMD::RESP_CODE || err_msg
+ err_msg = "recv erron #{@header[9]}, 0 is correct cmd: #{CMD::MAPPING_NAME[@cmd]}" unless @header[9] == 0 || err_msg
{status: err_msg.nil?, err_msg: err_msg}
end
def timeout_recv
Timeout.timeout(@recv_timeout) do
\ No newline at end of file