[Haskell-cafe] network package and SIGVTALRM
ruben.astud at gmail.com
Wed Jul 13 10:14:32 UTC 2016
On 12/07/16 11:40, Andrey Sverdlichenko wrote:
> they both reading what other one sends to them? Given that your code only
> fails on large files, I guess sender never reads this 4-byte status
> messages receiver sends to it, and processes deadlock after socket buffer
> is filled up.
Right on the nail. I played a bit with tcpdump/wireshark to see I was
just sending 0 length ACKs and multiple 4 byte messages joined on a
single packet. Seems TCP buffers tiny packets using a strategy called
Nagle's algorithm and thus joined all my packets on a bufferzone until a
threeshold. Then it sent them all at once, making the other end crazy.
Adding on a function that set-ups the socket this line
newSocket :: AddrInfo -> IO Socket
newSocket addr = do
sock <- socket AF_INET Stream defaultProtocol
setSocketOption sock NoDelay 1 -- this was added
connect sock (addrAddress addr)
makes the downloads go until the end. :-)
> As a side node, consider using putWord32be from binary or cereal packages
> instead of serializing data yourself.
Note taken. I just don't want to impose on a new dependency on my first
patch. I did copy/pasted putWord32be (at least on style) for my int2BS
Thanks a lot!
-- Ruben Astudillo
More information about the Haskell-Cafe