Beispiel #1
0
def client(host, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    s.sendall(launcelot.qa_pair[0][0].encode())
    answer1 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa_pair[1][0].encode())
    answer2 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa_pair[2][0].encode())
    answer3 = launcelot.recv_until(s, '.')
    print(answer1, answer2, answer3)
    s.close()
Beispiel #2
0
def client(host, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    s.sendall(launcelot.qa_pair[0][0].encode())
    answer1 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa_pair[1][0].encode())
    answer2 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa_pair[2][0].encode())
    answer3 = launcelot.recv_until(s, '.')
    print(answer1, answer2, answer3)
    s.close()
Beispiel #3
0
def client(hostname, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((hostname, port))
    s.sendall(launcelot.qa[0][0])
    answer1 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa[1][0])
    answer2 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa[2][0])
    answer3 = launcelot.recv_until(s, '.')
    s.close()
    print answer1
    print answer2
    print answer3
Beispiel #4
0
def client(hostname, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((hostname, port))
    s.sendall(launcelot.qa[0][0])
    answer1 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa[1][0])
    answer2 = launcelot.recv_until(s, '.')
    s.sendall(launcelot.qa[2][0])
    answer3 = launcelot.recv_until(s, '.')
    s.close()
    print answer1
    print answer2
    print answer3
Beispiel #5
0
def handle_client(sock):
    try:
        while True:
            q = launcelot.recv_until(sock, '?')
            a = launcelot.qa_dict[q]
            sock.sendall(a.encode())
    except EOFError as e:
        sock.close()
Beispiel #6
0
def handle_client(sock):
    try:
        while True:
            q = launcelot.recv_until(sock, '?')
            a = launcelot.qa_dict[q]
            sock.sendall(a.encode())
    except EOFError as e:
        sock.close()
Beispiel #7
0
def handle_client(client_sock):
    try:
        while True:
            question = launcelot.recv_until(client_sock, '?')
            answer = launcelot.qadict[question]
            client_sock.sendall(answer)
    except EOFError:
        client_sock.close()
Beispiel #8
0
def handle_client(client_sock):
    try:
        while True:
            question = launcelot.recv_until(client_sock, '?')
            answer = launcelot.qadict[question]
            client_sock.sendall(answer)
    except EOFError:
        client_sock.close()
Beispiel #9
0
def handle_client (client_sock):
    try:
        while True:
            question = launcelot.recv_until (client_sock, '?')
            answer = launcelot.qadict.get (question, "I don't understand your question.")
            client_sock.sendall (answer)
    except (EOFError, socket.error):
        client_sock.close()
Beispiel #10
0
def handle_client(sock):
    try:
        while True:
            q = launcelot.recv_until(sock, '?')
            a = launcelot.qa_dict[q]
            print('Question is:', q, "answer is:", a)
            sock.sendall(a.encode())
    except EOFError as e:
        sock.close()
Beispiel #11
0
 def test_dialog(self):
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.connect((SERVER_HOST, launcelot.PORT))
     for i in range(10):
         q, a = launcelot.qa_pair[i % len(launcelot.qa_pair)]
         sock.sendall(q)
         reply = launcelot.recv_until(sock, '.')
         self.assertEqual(reply, a)
     sock.close()
Beispiel #12
0
def handle_client(sock):
    try:
        while True:
            q = launcelot.recv_until(sock, '?')
            a = launcelot.qa_dict[q]
            print('Question is:', q, "answer is:", a)
            sock.sendall(a.encode())
    except EOFError as e:
        sock.close()
Beispiel #13
0
	def test_dialog (self):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect ((SERVER_HOST, launcelot.PORT))
		for i in range(3):
			for k, v in launcelot.qadict.items():
				sock.sendall (k)
				reply = launcelot.recv_until(sock, '.')
				self.assertEqual (reply, v)
		sock.close()
Beispiel #14
0
def client (hostname, port):
    s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
    s.connect ((hostname, port))
    answers=[]
    for k in launcelot.qadict.keys():
        s.sendall (k)
        a = launcelot.recv_until (s, '.')
        answers.append(a)
    s.close()
    for a in answers:
        print a