##// END OF EJS Templates
imanay -
r53:54
parent child
Show More
@@ -1,14 +1,18
1 import socket
1 import socket
2
2
3 #host = "localhost"
4 host = "192.168.1.117"
5 #host = "192.168.1.100"
3 s = socket.socket()
6 s = socket.socket()
4 s.connect(("localhost", 5500))
7 s.connect((host, 5500))
5
8
6 while True:
9 while True:
7 mensaje = raw_input("> ")
10 mensaje = raw_input("> ")
8 s.send(mensaje)
11 s.send(mensaje)
9 if mensaje == "quit":
12 if mensaje == "quit":
10 break
13 break
11
14 recibido = s.recv(1024)
15 print "Recibido:", recibido
12 print "adios"
16 print "adios"
13
17
14 s.close() No newline at end of file
18 s.close()
@@ -1,19 +1,20
1 import socket
1 import socket
2
2
3 host = "192.168.1.117"
3 s = socket.socket()
4 s = socket.socket()
4 s.bind(("localhost", 5500))
5 s.bind((host, 5500))
5 s.listen(1)
6 s.listen(1)
6
7
7 sc, addr = s.accept()
8 sc, addr = s.accept()
8
9
9 while True:
10 while True:
10 recibido = sc.recv(1024)
11 recibido = sc.recv(1024)
11 if recibido == "quit":
12 if recibido == "quit":
12 break
13 break
13 print "Recibido:", recibido
14 print "Recibido:", recibido
14 sc.send(recibido)
15 sc.send(recibido)
15
16
16 print "adios"
17 print "adios"
17
18
18 sc.close()
19 sc.close()
19 s.close() No newline at end of file
20 s.close()
General Comments 0
You need to be logged in to leave comments. Login now