TCP server haskell string comparison

前端 未结 1 328
故里飘歌
故里飘歌 2021-01-20 01:17

I have a small server written in Haskell, when I send something to it, it should evaluate if the sent content matches a password \"password\" in the auth function but it is

1条回答
  •  孤城傲影
    2021-01-20 01:42

    I see a number of issues here.

    • You should flush Handle after hPutStr h "connected". IIRC the Handle is buffered. So probably everything is ok, but you don't see the connected message on client side because of buffering. (ADDED: use hFlush h)

    • Some clients (e.g. telnet) uses \r\n as end-of-line mark, but hGetLine expects \n. So you may receive password\r instead of password. Try print msg instead of putStrLn msg to see what exactly you received.

    0 讨论(0)
提交回复
热议问题