I developed a server in C++ and I would like to develop an interface in Ruby On Rails.
So I started to read http://ruby.railstutorial.org/ , meanwhile I start looking if I would be able to create a connection between my Ruby On Rails application and my server.
I find out I could use TCPSocket.
My question is : Could I open just 1 TCPSocket by session (and store it somewhere) ?
Or would I have to open a TCPSocket for every action in my controllers ?
Thanks in advance,
app/models/conn.rb:
class Conn
@connection = "foo" # Connect here
def self.get_connection
@connection
end
end
Rails console:
irb(main):002:0> Conn.get_connection
=> "foo"
But unless your server is single-threaded you will have more than one connection anyways.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.