
Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following: sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client. At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere. It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill. Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way? Thanks again Raf

On Sat, Jun 18, 2011 at 1:01 PM, Raphael Päbst
Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following:
sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client.
At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere.
Have you looked at how you're buffering the handles? Have you experimented with changing the buffering mode or using the hFlush function? Antoine
It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill.
Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way?
Thanks again
Raf
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

I am currently using line buffering and I tried hFlush on both server
and client side so far.
On 6/18/11, Antoine Latter
On Sat, Jun 18, 2011 at 1:01 PM, Raphael Päbst
wrote: Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following:
sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client.
At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere.
Have you looked at how you're buffering the handles? Have you experimented with changing the buffering mode or using the hFlush function?
Antoine
It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill.
Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way?
Thanks again
Raf
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

There is a chapter on this in the book "Real World Haskell" which I
believe is also online. :)
On Sat, Jun 18, 2011 at 12:37 PM, Raphael Päbst
I am currently using line buffering and I tried hFlush on both server and client side so far.
On 6/18/11, Antoine Latter
wrote: On Sat, Jun 18, 2011 at 1:01 PM, Raphael Päbst
wrote: Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following:
sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client.
At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere.
Have you looked at how you're buffering the handles? Have you experimented with changing the buffering mode or using the hFlush function?
Antoine
It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill.
Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way?
Thanks again
Raf
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- -- Regards, KC

If you mean the network chapter, then I have read this and in fact
taken most of the code for the TCP server from there.
If you mean another, then please tell me which one.
On 6/18/11, KC
There is a chapter on this in the book "Real World Haskell" which I believe is also online. :)
On Sat, Jun 18, 2011 at 12:37 PM, Raphael Päbst
wrote: I am currently using line buffering and I tried hFlush on both server and client side so far.
On 6/18/11, Antoine Latter
wrote: On Sat, Jun 18, 2011 at 1:01 PM, Raphael Päbst
wrote: Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following:
sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client.
At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere.
Have you looked at how you're buffering the handles? Have you experimented with changing the buffering mode or using the hFlush function?
Antoine
It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill.
Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way?
Thanks again
Raf
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- -- Regards, KC

Hi:
I meant the network chapter.
How is what you're doing different than the network chapter?
On Sat, Jun 18, 2011 at 12:55 PM, Raphael Päbst
If you mean the network chapter, then I have read this and in fact taken most of the code for the TCP server from there.
If you mean another, then please tell me which one.
On 6/18/11, KC
wrote: There is a chapter on this in the book "Real World Haskell" which I believe is also online. :)
On Sat, Jun 18, 2011 at 12:37 PM, Raphael Päbst
wrote: I am currently using line buffering and I tried hFlush on both server and client side so far.
On 6/18/11, Antoine Latter
wrote: On Sat, Jun 18, 2011 at 1:01 PM, Raphael Päbst
wrote: Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following:
sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client.
At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere.
Have you looked at how you're buffering the handles? Have you experimented with changing the buffering mode or using the hFlush function?
Antoine
It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill.
Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way?
Thanks again
Raf
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- -- Regards, KC
-- -- Regards, KC

Mainly I'd say it's that I want to send the answer back via the same
handle. That's where the problem comes from, I suspect. Since it is
lazy IO, it only evaluates, once the handle gets closed from the
client side. And then it is too late to send something back. At least
that's how I understand it.
On 6/18/11, KC
Hi:
I meant the network chapter.
How is what you're doing different than the network chapter?
On Sat, Jun 18, 2011 at 12:55 PM, Raphael Päbst
wrote: If you mean the network chapter, then I have read this and in fact taken most of the code for the TCP server from there.
If you mean another, then please tell me which one.
On 6/18/11, KC
wrote: There is a chapter on this in the book "Real World Haskell" which I believe is also online. :)
On Sat, Jun 18, 2011 at 12:37 PM, Raphael Päbst
wrote: I am currently using line buffering and I tried hFlush on both server and client side so far.
On 6/18/11, Antoine Latter
wrote: On Sat, Jun 18, 2011 at 1:01 PM, Raphael Päbst
wrote: Hey everyone! Sorry for asking more or less the same question again, but I'm still stuck wrestling with lazy IO. What I'm trying to do is the following:
sending a Bytestring to a server, via TCP Do stuff with the Bytestring that results in another Bytestring Send that new Bytestring back to the original client.
At the moment this all happens inside an IO handle and doesn't work. The stuff on the server side only gets executed, once the handle is closed on the client's side and therefore the response is lost somewhere.
Have you looked at how you're buffering the handles? Have you experimented with changing the buffering mode or using the hFlush function?
Antoine
It's a very simple program otherwise and so I don't want to get too much into iteratees, iterators and that stuff, since it feels like overkill.
Is there a way to get this working in the way I'm currently trying? Or can I do this in a strict way?
Thanks again
Raf
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- -- Regards, KC
-- -- Regards, KC

On Sat, Jun 18, 2011 at 10:26 PM, Raphael Päbst
Mainly I'd say it's that I want to send the answer back via the same handle. That's where the problem comes from, I suspect. Since it is lazy IO, it only evaluates, once the handle gets closed from the client side. And then it is too late to send something back. At least that's how I understand it.
No it don't work like that, what's more probably happening is that your program is structured so that the answer can't be created until the "end" of the "request" is read and this "end" won't appear until eof has been received. You should make it explicit in your request that it is finished (send two empy lines at the end of the request for instance). If you don't manage to do that, show us your code so that we could point out your mistake. -- JedaÏ

I think, you're right. I read the ByteString from the handle using
hGetContents, which then waits for eof, which I don't send apparently.
Is there a way to do this explicitely?
Raf
On 6/19/11, Chaddaï Fouché
On Sat, Jun 18, 2011 at 10:26 PM, Raphael Päbst
wrote: Mainly I'd say it's that I want to send the answer back via the same handle. That's where the problem comes from, I suspect. Since it is lazy IO, it only evaluates, once the handle gets closed from the client side. And then it is too late to send something back. At least that's how I understand it.
No it don't work like that, what's more probably happening is that your program is structured so that the answer can't be created until the "end" of the "request" is read and this "end" won't appear until eof has been received. You should make it explicit in your request that it is finished (send two empy lines at the end of the request for instance). If you don't manage to do that, show us your code so that we could point out your mistake.
-- JedaÏ

Yes, close the socket (-: On Jun 19, 2011, at 7:53 AM, Raphael Päbst wrote:
I think, you're right. I read the ByteString from the handle using hGetContents, which then waits for eof, which I don't send apparently. Is there a way to do this explicitely?
Raf
On 6/19/11, Chaddaï Fouché
wrote: On Sat, Jun 18, 2011 at 10:26 PM, Raphael Päbst
wrote: Mainly I'd say it's that I want to send the answer back via the same handle. That's where the problem comes from, I suspect. Since it is lazy IO, it only evaluates, once the handle gets closed from the client side. And then it is too late to send something back. At least that's how I understand it.
No it don't work like that, what's more probably happening is that your program is structured so that the answer can't be created until the "end" of the "request" is read and this "end" won't appear until eof has been received. You should make it explicit in your request that it is finished (send two empy lines at the end of the request for instance). If you don't manage to do that, show us your code so that we could point out your mistake.
-- JedaÏ
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Won't that make it impossible to send stuff back to the original sender?
On 6/19/11, Sean Perry
Yes, close the socket (-:
On Jun 19, 2011, at 7:53 AM, Raphael Päbst wrote:
I think, you're right. I read the ByteString from the handle using hGetContents, which then waits for eof, which I don't send apparently. Is there a way to do this explicitely?
Raf
On 6/19/11, Chaddaï Fouché
wrote: On Sat, Jun 18, 2011 at 10:26 PM, Raphael Päbst
wrote: Mainly I'd say it's that I want to send the answer back via the same handle. That's where the problem comes from, I suspect. Since it is lazy IO, it only evaluates, once the handle gets closed from the client side. And then it is too late to send something back. At least that's how I understand it.
No it don't work like that, what's more probably happening is that your program is structured so that the answer can't be created until the "end" of the "request" is read and this "end" won't appear until eof has been received. You should make it explicit in your request that it is finished (send two empy lines at the end of the request for instance). If you don't manage to do that, show us your code so that we could point out your mistake.
-- JedaÏ
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (5)
-
Antoine Latter
-
Chaddaï Fouché
-
KC
-
Raphael Päbst
-
Sean Perry