Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix port #30

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions sample_code/Python/src/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import socket

HOST = "10.201.77.56" # localhost
PORT = 1234 # pixelflut-port


with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect((HOST, PORT))

## Commands available:
## - Get Help: HELP
## - Retrieve color value of pixel at coordinate (x|y): PX <x> <y>
## - Color the pixel at coordinate (x|y) in color c (format rrggbb): PX <x> <y> <c>
## - Get canvas size: SIZE
## - Set offset of width w and height h for the duration of the connection: OFFSET <w> <h>

sock.sendall(b"SIZE\n")
print(sock.recv(1024))

sock.sendall(b"OFFSET 20 20\n")
msg = bytes(f"PX 13 37 FF0000\n", "UTF-8")
sock.sendall(msg)

sock.sendall(b"PX 13 37\n")
print(sock.recv(1024))

## If you want to received messages, handling might look like this
# data = sock.rcv(1024)
# print(f"{data!r}")