[Haskell] HGetChar socket reading
Tobe
tobe at playahs.de
Thu May 12 18:09:36 EDT 2005
hey guys !
IŽm pretty nu to haskell, and i got the following things to do:
code a client in python that sends string ->done
code a server in haskell that recieves string -> to do...
i initialized the server, set up a socket on port 9900,
so the socket is allready open...
First i read the string with hGetLine:
loop socket =
do
(handle, host, port) <- accept socket
forkIO (client handle)
loop socket
client handle = do
query <- hGetLine handle
this worked pretty good.
Now my Tutor said, I should code this whole thing with hGetChar
instead of hGetLine...
I ainŽt got the clue of an clue how to manage this...
I worked something out like:
client handle = do
query <- hGetChar handle
if query = [] then return(0)
else
let list = list ++ query
I donŽt know where the string is stored in the handle,
and how to read it out...I mean, I canŽt use stuff like
query handle <- hGetChar(firstfrom:query handle)...
Please Help Me !!!
More information about the Haskell
mailing list