Module: Net

Defined in:
lib/common/socket/net.rb

Overview

网络交互服务顶层接口e.g. nshead_send, shead_send

Author

chenjie

Data

2009-4-30

Instance Method Summary collapse

Instance Method Details

#g_send(host, querykey, driver, headtype, datapath, datafile, resultpath, resultfile) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/common/socket/net.rb', line 40

def g_send(host, querykey, driver, headtype, datapath, datafile, resultpath, resultfile)
	my_client_path=TOOL_ROOT+"net/my_client/"
	send_cmd="cd #{my_client_path} && ./my_client -q #{querykey} -d #{driver} -t #{headtype} -a #{host} -p #{datapath} -c #{datafile} -r #{resultpath} -f #{resultfile}"

	system "#{send_cmd}"

end

#nshead_send(ip, port, nshead_hash, send_data_file, recv_data_file) ⇒ Object

功能

向指定目标发送指定内容的mcpack包(mcsend)

params:

ip: 目标机器ip port: 目标机器端口nshead hash: 定制的nshead文件路径(需要指定nshead头参数时使用,NULL表示使用默认值) send_data_file: 待发送mcpack文本路径recv_data_file: 待接收另存的mcpack文本路径

example

nshead_send “127.0.0.1”, 3390, nsheadhash, sendfile, recvfile



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/common/socket/net.rb', line 24

def nshead_send(ip, port, nshead_hash, send_data_file, recv_data_file)
	ms_path=TOOL_ROOT+"net/mcsend/"
	nshead_file = "nshead.data"
	if nil != nshead_hash then
 #TODO: modify nshead_file according to the nshead_hash
 Env.modify_conf('127.0.0.1',USERNAME, PASSWORD, ms_path + nshead_file, nshead_hash)
	end
      send_cmd = "cd #{ms_path} && ./mcsend -s -i #{ip} -p #{port} -n #{nshead_file} -b #{send_data_file} -o #{recv_data_file} "
	$log.debug send_cmd
	system "#{send_cmd}"
end

#send_mcpack(host, headtype, datapath, datafile, resultpath, resultfile) ⇒ Object



48
49
50
51
52
53
# File 'lib/common/socket/net.rb', line 48

def send_mcpack(host, headtype, datapath, datafile, resultpath, resultfile)
	my_client_path=TOOL_ROOT+"net/my_client/"
	send_cmd="cd #{my_client_path} && ./my_client -t #{headtype} -a #{host} -p #{datapath}  -c #{datafile} -r #{resultpath} -f #{resultfile}"

	system "#{send_cmd}"
end

#shead_send(ip, port, send_data_file, recv_data_file, diver = nil) ⇒ Object



37
38
# File 'lib/common/socket/net.rb', line 37

def shead_send(ip, port, send_data_file, recv_data_file, diver=nil)
end