Esempio n. 1
0
 def writeToNet(self, value):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     # put a header so the app_support server knows what to do with the data string
     d_item = DataItem(value)
     msg = "WRITE_DATA|" + d_item.key + "|" + d_item.value
     # send the data and return
     client.connect_send__receive_close(self.host, self.port, msg)
     return d_item.key
Esempio n. 2
0
 def deleteFromNet(self, key):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     # put a header so the app_support server knows what to do with the data string
     msg = "DELETE|" + key
     # send the data and return
     return client.connect_send__receive_close(self.host, self.port, msg)
Esempio n. 3
0
 def joinNetwork(self):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     msg = "JOIN_NETWORK|"
     # send the data and return
     response = client.connect_send__receive_close(self.host, self.port, msg)
     return response
Esempio n. 4
0
 def findPeer(self):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     msg = "FIND_PEER|" + self.host
     # send the data and return
     response = client.connect_send__receive_close(self.host, self.port, msg)
     return response
Esempio n. 5
0
 def locateHash(self, hash):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     msg = "LOOKUP|" + hash
     # send the data and return
     response = client.connect_send__receive_close(self.host, self.port, msg)
     return response
Esempio n. 6
0
 def DumpPeerData(self):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     msg = "DUMP_PEER_DATA|"
     # send the data and return
     response = client.connect_send__receive_close(self.host, self.port, msg)
     return response
Esempio n. 7
0
 def readFromNet(self, key):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     # put a header so the app_support server knows what to do with the data
     # string
     msg = "READ_DATA|{0}".format(key)
     # send the data and return
     return client.connect_send__receive_close(self.host, self.port, msg)
Esempio n. 8
0
 def hasListener(self):
     response = ""
     client = Simple_Client(self.host, self.port)
     try:
         response = client.connect_send__receive_close(self.host, self.port, "PING|")
     except:
         return False
     if response == "OK":
         return True
     return False
Esempio n. 9
0
    def getNeighbors(self, mode):
        # we need a client to talk to the peer head
        client = Simple_Client(self.host, self.port)
        if mode == "FULL":
            msg = "GET_NET_STAT|FULL"
        else:
            msg = "GET_NET_STAT|CSV"

        # send the data and return
        return client.connect_send__receive_close(self.host, self.port, msg)
Esempio n. 10
0
    def getNeighbors(self, mode):
        # we need a client to talk to the peer head
        client = Simple_Client(self.host, self.port)
        if mode == "FULL":
            msg = "GET_NET_STAT|FULL"
        else:
            msg = "GET_NET_STAT|CSV"

        # send the data and return
        response = client.connect_send__receive_close(self.host, self.port, msg)
        return response
Esempio n. 11
0
 def leaveNetwork(self):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     msg = "LEAVE_NETWORK|"
     # send the data and return
     return client.connect_send__receive_close(self.host, self.port, msg)
Esempio n. 12
0
 def networkSize(self):
     # we need a client to talk to the peer head
     client = Simple_Client(self.host, self.port)
     msg = "NETWORK_SIZE|"
     # send the data and return
     return client.connect_send__receive_close(self.host, self.port, msg)