5

I have a third party app running on a server, which authenticates the client and responses back.

My problem here is for each and every request that I get to my rails app I need to establish a TCP connection and get the data. Is it possible to have a persistent connection so that I can reduce overhead in establishing the connection.

Vivek Dhayalan
  • 467
  • 4
  • 28

1 Answers1

0

I hope you are using ruby socket. I think you can have a method which will return a connection object. You can have a class variable for connection object. method will check if connection then return otherwise create new one.

 self.get_connection
   return @@conObj if @@conObj 
   return @@conObj = TCPSocket::new( "192.168.1.1", 100 )
 end

I'm not sure but it might help you.

Ashish
  • 5,723
  • 2
  • 24
  • 25