Discuss Scratch

KWSmit
New to Scratch
1 post

No response from Scratch Link

Hi,
I'm new to Scratch and try to understand how Scratch Link works.
I wrote a simple Python script to connect to Scratch Link throug a websocket:

```
import json
import socket

HOST = ‘127.0.0.1’ # Localhost
PORT = 20110 # Port to listen on

req_version_json = {
“jsonrpc”: “2.0”,
“id”: 1,
“method”: “getVersion”
}

# Serialize and convert to bytes
request_version = json.dumps(req_version_json).encode('UTF-8')

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
err = s.connect((HOST, PORT))
print('Connected (err: {})'.format(err))
r = s.send(request_version)
print('Bytes send: {}\nWaiting voor response…'.format(r))
res = s.recv(4096)
print('Response: {}'.format(res.decode()))
```
Connecting succeeds (err=0) and the message was sent correctly. I can see in Windows TCP-viewer that Scratch Link received all the bytes of the message. But I get no response on s.recv().

What am I doing wrong?

Powered by DjangoBB

Standard | Mobile