Python Forum
managing SOCK.STREAM digit values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
managing SOCK.STREAM digit values
#1
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:
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()
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  want to stream rtsp from my Pi camera korenron 0 2,348 Dec-28-2020, 08:23 AM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020