-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientSocket.py
More file actions
27 lines (24 loc) · 908 Bytes
/
Copy pathClientSocket.py
File metadata and controls
27 lines (24 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
import socket
import sys
import numpy as np, cv2
localip = 'localhost'
raspip = '192.168.1.5'
ip = raspip
clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)# creamos el socket
clientsocket.connect((ip,8000))# ahora hacemos que se conecte con el servidor
while 1:
data = raw_input() #f recibimos datos del usuario
if not data: #si no hay datos, terminamos
break
if ':' in data:#si el formato introducido es el correcto
data += ';'
clientsocket.send(data.encode('utf-8')) # enviamos los dtaos al servidor
newdata = clientsocket.recv(1024).decode('utf-8') # recibimos acknowledge del servidor
print ('servidor: %s' % newdata)
if 'exit' in data: #en este caso, salimos
clientsocket.close()
sys.exit()
else:
print('Orden no valida')
clientsocket.close()