23 lines
516 B
Python
23 lines
516 B
Python
|
# server.py
|
||
|
# simple listener to an IP port to test the phomemo plugin
|
||
|
|
||
|
import socket
|
||
|
|
||
|
PORT = 9100 # Port to listen on
|
||
|
|
||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||
|
s.bind(('', PORT))
|
||
|
s.listen(1)
|
||
|
while True:
|
||
|
conn, addr = s.accept()
|
||
|
print(addr)
|
||
|
while True:
|
||
|
data = conn.recv(9100)
|
||
|
print('data received')
|
||
|
print('Sending to printer...')
|
||
|
|
||
|
printer=open('test.png','wb')
|
||
|
printer.write(data)
|
||
|
printer.close()
|
||
|
if not data:
|
||
|
break
|