Commit 23bd65f4 authored by Ignacio Corderi's avatar Ignacio Corderi
Browse files

Added handshake to connect

parent 0c51acbd
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import struct
import common
import kinetic_pb2 as messages
import ssl
import operations

ss = socket

@@ -139,6 +140,16 @@ class BaseClient(object):
        self.connection_id = int(time.time())
        self._closed = False

        self._handshake()

    def _handshake(self):
        # Connection id handshake
        h,v = operations.Noop.build()
        self.update_header(h)
        self.network_send(h,v)
        r = self.network_recv()
        print "Connection: " + str(self.connection_id)

    def has_data_available(self):
        tmp = self._socket.recv(1, socket.MSG_PEEK)
        return len(tmp) > 0
@@ -288,6 +299,7 @@ class BaseClient(object):
        resp = self._recv_delimited_v2()

        # update connectionId to whatever the drive said.
        if resp[0].command.header.connectionID:
            self.connection_id = resp[0].command.header.connectionID

        return resp