summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary/SocketKeywords.py
diff options
context:
space:
mode:
Diffstat (limited to 'robotframework-onap/ONAPLibrary/SocketKeywords.py')
-rw-r--r--robotframework-onap/ONAPLibrary/SocketKeywords.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/robotframework-onap/ONAPLibrary/SocketKeywords.py b/robotframework-onap/ONAPLibrary/SocketKeywords.py
new file mode 100644
index 0000000..08a3fc7
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/SocketKeywords.py
@@ -0,0 +1,18 @@
+import socket
+from robot.api.deco import keyword
+
+
+class SocketKeywords(object):
+ """SocketKeywords are common resource for simple socket keywords."""
+
+ def __init__(self):
+ super(SocketKeywords, self).__init__()
+
+ @keyword
+ def send_binary_data(self, host, port, data):
+ """ send raw bytes over tcp socket"""
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ # Connect to server and send data
+ sock.connect((host, int(port)))
+ sock.sendall(bytes(data))
+ sock.close()