Mar-18-2021, 07:08 PM
Hello Everybody.
Beginner and first post here.
i need some help because i can't manage the socket(SOCK.STREAM) object.
the script i'm using is the following:
i'm sending an ''audio'' signal from PureData(with netsend object) to Python, the values sent are transalted as values from 0 to 99 (is going to a volume value).
and let's say that i'm sending a constant value of 89.
what i get on Python is:
received 89898989
received 89898989
received 898989
received 89898989
..
why i get 4 couples value at the time instead of 2 digits like this?:
received 89
received 89
...
this is what happens when i change the value sent from PureData
received 67676767
received 67676871
received 7274778184
received 87878989
received 89898989
...
any help appreciated.
Beginner and first post here.
i need some help because i can't manage the socket(SOCK.STREAM) object.
the script i'm using is the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import socket import sys sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ( 'localhost' , 3000 ) print ( f 'starting up on {server_address[0]} port {server_address[1]}' ) sock.bind(server_address) sock.listen( 1 ) while True : print ( 'waiting for a connection' ) connection, client_address = sock.accept() # try : print ( 'client connected:' , client_address) while True : data = connection.recv( 1024 ) data = data.decode( "utf-8" ) data = data.replace( '\n' , ' ').replace(' \t ',' ').replace(' \r ',' ').replace(' ; ',' ') print ( f 'received {data}' ) if not data: break finally : connection.close() |
and let's say that i'm sending a constant value of 89.
what i get on Python is:
received 89898989
received 89898989
received 898989
received 89898989
..
why i get 4 couples value at the time instead of 2 digits like this?:
received 89
received 89
...
this is what happens when i change the value sent from PureData
received 67676767
received 67676871
received 7274778184
received 87878989
received 89898989
...
any help appreciated.