Hope you are using a ruby socket. I think you may have a method that will return a connection object. You may have a class variable for the connection object. the method will check if the connection then returns otherwise, create a new one.
self.get_connection
return @@conObj if @@conObj
return @@conObj = TCPSocket::new( "192.168.1.1", 100 )
end
I'm not sure, but that might help you.
source
share