From 38573dcd402209eaec0a168ba22494645778ac6d Mon Sep 17 00:00:00 2001 From: Adam Long Date: Thu, 28 Jul 2016 15:22:59 -0400 Subject: [PATCH] added client code and made names more logical --- ds.py | 33 +++++++++++++++++++++++++++++++++ server.py => rpi.py | 0 2 files changed, 33 insertions(+) create mode 100644 ds.py rename server.py => rpi.py (100%) diff --git a/ds.py b/ds.py new file mode 100644 index 0000000..d790e87 --- /dev/null +++ b/ds.py @@ -0,0 +1,33 @@ +import socket +import pygame +import sys + +host = "192.168.1.136" +port=5802 +screen = pygame.display.set_mode((640,480),0) + + +while True: + clientsocket=socket.socket(socket.AF_INET, socket.SOCK_STREAM) + clientsocket.connect((host, port)) + received = [] + # loop .recv, it returns empty string when done, then transmitted data is completely received + while True: + #print("esperando receber dado") + recvd_data = clientsocket.recv(230400) + if not recvd_data: + break + else: + received.append(recvd_data) + + dataset = ''.join(received) + print(len(dataset)) + image = pygame.image.fromstring(dataset,(640,480),"RGB") # convert received image from string + screen.blit(image,(0,0)) # "show image" on the screen + pygame.display.update() + + # check for quit events + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() \ No newline at end of file diff --git a/server.py b/rpi.py similarity index 100% rename from server.py rename to rpi.py