Opened 4 months ago
Sequent reading from socket/connection on Windows fails
|Reported by:||Heimdell||Owned by:|
|Keywords:||sockets, windows, read failure||Cc:|
|Type of failure:||Incorrect result at runtime||Difficulty:||Unknown|
|Test Case:||Blocked By:|
I wrote a simple TCP-client, which consumes and produces 8-byte packets.
When I run it on linux, it works perfectly, being part of the loop (write-read-write-read-...).
On windows it receives only first msg from the other side (write-read-write-write-...). The packets are still going, although.
Before that, I used the sockets directly; changing to HandleStream? didn't help.
The code is:
transmit :: Int -> HandleStream ByteString -> ByteString -> IO [Bytestring] transmit delay sock packet = do let input = timeout delay $ sock `readBlock` 8 <* putStrLn "\nData was read!" sock `writeBlock` pack strings <- whileJust input return [str | Right str <- strings] whileJust action = do result <- action case result of Just a -> (:) <$> return a <*> whileJust action Nothing -> return