예제 #1
0
파일: tools.py 프로젝트: Tefx/Littlefinger
	def listen(self, host):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect((host, SERVICE_PORT))
		port = Port(sock)
		port.write(self.subs)
		while True:
			res = port.read()
			if res:
				self.queue.put(res)
예제 #2
0
파일: tools.py 프로젝트: Tefx/Littlefinger
class Source(object):
	def __init__(self, host):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect((host, SERVICE_PORT))
		self.port = Port(sock)

	def sendall(self, list):
		for item in list:
			self.port.write(item)

	def send(self, item):
		self.port.write(item)
예제 #3
0
파일: agent.py 프로젝트: Tefx/Thinkpol
class Agent(object):
	def __init__(self, addr):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect(addr)
		self.port = Port(sock)

	def list(self):
		self.port.write("?")
		return json.loads(self.port.read())

	def fetch(self, want="*"):
		if want == "*":
			req = "*"
		else:
			req = json.dumps(want)
		self.port.write(req)
		return json.loads(self.port.read())