HomeAboutMailing ListList Chatter /0/0 98.80.143.34

Straws

2024-08-12 by: Erica Wolf via chugalug
From: Erica Wolf via chugalug 
------------------------------------------------------
I am trying to write binary packets in Python. I am getting the packets
from a socket.recv function. What gets written is shorter than expected:

Written Length: 9728
Expected Length: 65536
Written Length: 1403568
Expected Length: 9455616

The RECV function lets me specify a number of bytes to receive, but the
binary file WRITE function does not. I am assuming it's stopping on 0s. But
this data probably contains zeros.

I keep Googling for solutions but they always show something like
write(b"\x48\x65\x6C\x6C\x6F") which is not useful, because Python is
managing the bytes and terminating with a NUL.

What is the best solution? I can't believe that Python doesn't provide a
write(data, length) option!

-Erica
-=--=---=----=----=---=--=-=--=---=----=---=--=-=-
Erica Wolf (she/her)

=============================================================== From: Erica Wolf via chugalug ------------------------------------------------------ And it turns out that socket.recv isn't even getting the full payload. -=3D--=3D---=3D----=3D----=3D---=3D--=3D-=3D--=3D---=3D----=3D---=3D--=3D-= =3D- Erica Wolf (she/her) On Mon, Aug 12, 2024 at 11:54=E2=80=AFAM Erica Wolf wrot= e: ut -=3D-

=============================================================== From: Deidre Holtsclaw via chugalug ------------------------------------------------------ Do you still need this? I have people I can ask. Pablo Galindo Salgado works in our London office and Sarah Monod works on my floor (she's a core Python developer, though everything prior to a couple of months ago is under a different name). -=3D- ote: But =3D-=3D-

=============================================================== From: Erica Wolf via chugalug ------------------------------------------------------ I don't need it any more. It turned out that socket.recv(bytes) wasn't actually receiving all the bytes. I wrote a wrapper for recv that would block up to 5 second or until all the bytes were received. -=3D--=3D---=3D----=3D----=3D---=3D--=3D-=3D--=3D---=3D----=3D---=3D--=3D-= =3D- Erica Wolf (she/her) e =3D-=3D- rote: : But a =3D-=3D-