我找到了解决这个问题的办法。通过应用来自
a previous question
,我将代码改为:
服务器
:
需要“socket”
server = TCPServer.open(2000)
loop {
client = server.accept
filename = client.gets.chomp
puts "Reading contents of #{filename}.raw"
raw_data = client.gets("\r\r\n\n").chomp("\r\r\n\n")
file = File.open(filename + ".raw", 'wb')
file.print raw_data
file.close
puts "Converting #{filename}"
#It's lame to have a script run a script, but it's the only way to get this to work.
system "scriptit.bat " + filename + ".raw"
puts "Sending contents of #{filename}.mzML"
data = IO.read(filename + ".mzML")
client.print data
client.print "\r\r\n\n"
puts "Done"
client.close
}
顾客
:
host = config_value("//Host/@ip")
port = 2000
client = TCPSocket.open(host, port)
fileName = @file.split("/")[-1].chomp(File.extname(@file))
puts "Sending raw file"
client.puts fileName
data = IO.read("#{@file}")
client.print data
client.print "\r\r\n\n" #This is the delimiter for the server
puts "Receiving mzML file"
file = File.open("#{$path}../data/spectra/#{fileName}.mzML", 'wb')
data = client.gets("\r\r\n\n")
file.print data
client.close
似乎扩展IO一行程序可以解决我的大部分大型文件Ruby问题。