ruby_kpi 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ ##################################################
2
+ #
3
+ # The TCPConnection class
4
+ #
5
+ ##################################################
6
+
7
+ module RubyKpi
8
+
9
+ class TCPConnection
10
+
11
+ # Constructor
12
+ def initialize(ip, port)
13
+
14
+ # Read parameters
15
+ @ip = ip
16
+ @port = port
17
+
18
+ # Connect
19
+ begin
20
+ @sib_socket = TCPSocket.new(@ip, @port)
21
+ rescue Errno::ECONNREFUSED
22
+ raise SIBError, 'Connection refused'
23
+ end
24
+ end
25
+
26
+ # Send the request message
27
+ def send_request(msg)
28
+ @sib_socket.write(msg)
29
+ end
30
+
31
+ # Receive the reply
32
+ def receive_reply()
33
+ rmsg = ""
34
+ while true do
35
+ begin
36
+ r = @sib_socket.recv(4096)
37
+ rmsg += r
38
+ if rmsg.include?("</SSAP_message>")
39
+ break
40
+ end
41
+ rescue
42
+ raise SIBError, 'Error while receiving a reply'
43
+ end
44
+ end
45
+
46
+ return rmsg
47
+ end
48
+
49
+ # Close the connection
50
+ def close()
51
+ @sib_socket.close()
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,3 @@
1
+ module RubyKpi
2
+ VERSION = "0.0.1"
3
+ end