summaryrefslogtreecommitdiff
path: root/inverterd
diff options
context:
space:
mode:
Diffstat (limited to 'inverterd')
-rw-r--r--inverterd/inverterd.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/inverterd/inverterd.py b/inverterd/inverterd.py
index 9f07c2e..5b9541e 100644
--- a/inverterd/inverterd.py
+++ b/inverterd/inverterd.py
@@ -11,8 +11,15 @@ class Format(Enum):
class Client:
def __init__(self, port=8305, host='127.0.0.1'):
+ self._host = host
+ self._port = port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.connect((host, port))
+
+ def __del__(self):
+ self.sock.close()
+
+ def connect(self):
+ self.sock.connect((self._host, self._port))
def _write(self, line):
self.sock.sendall((line+'\r\n').encode())