Skip to content

Instantly share code, notes, and snippets.

@aktowns
Created January 23, 2013 02:58
Show Gist options
  • Save aktowns/4601464 to your computer and use it in GitHub Desktop.
Save aktowns/4601464 to your computer and use it in GitHub Desktop.
let rec readUntilEOL' (line: string) (stream: NetworkStream) : Async<String> =
printfn "readUntilEOL': %s %A" line stream
async {
if line.EndsWith(String.NLCR) then return line
else
let! output = stream.AsyncRead(1)
let! result = readUntilEOL' (line + Encoding.ASCII.GetString(output)) stream
return result
}
let readUntilEOL : (NetworkStream -> Async<String>) = (readUntilEOL' "")
//Works:
readUntilEOL' "" stream
//Hangs:
readUntilEOL stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment