Hi,
On Sunday 14 June 2009 10:20:20 davidamoros wrote:
> Hello,
>
> I know this is a newbie question but here it goes anyway...
>
> I have a server listening on port 8000, attending petitions, and
> tested it with telnet
I think this is the same question that hit the IRC channel around the same
time today here:
http://www.kamaelia.org/logs/kamaelia2009-06-14_log.html
Past that discussion, reading this:
> As I see on
> http://www.kamaelia.org/Components/pydoc/Kamaelia.Util.OneShot.html, a
> single petition could be done with
> Pipeline(OneShot("lookup function"),
> TCPClient("localhost",8000),
> ConsoleEchoer()
> ).run()
> But the message doesn't get to the server... any hints on this?
I think it's useful to summarise why this won't work as is in the expected
way. Specifically, this fails due to interaction of shutdown messages:
OneShot - sends producerFinished out "signal" after sending it's message
TCPClient - shuts down when it recieves a producerFinished message.
* Should it?
As a result, no data reaches the ConsoleEchoer, and in some cases, no data
reaches the server either - since this essentially forms a race.
As noted on the channel, this is expected behaviour, rather than unexpected
because TCPClient can't know if it's being used as "fire and
forget", "receive only", or "half duplex bidirectional" or "full duplex
bidirectional".
It does mean that this example above, which is as you noted in the docs, is
wrong, and needs fixing. As noted in this code:
http://code.google.com/p/kamaelia/source/browse/trunk/Sketches/MPS/Examples/OneShot_Race.py
This example works:
Graphline(
CLIENT_PROTOCOL=Seq(
OneShot("Hello1\r\n"),
OneShot("Hello2\r\n"),
OneShot("Hello3\r\n"),
OneShot("Hello4\r\n"),
OneShot("Hello5\r\n"),
OneShot("Hello6\r\n"),
OneShot("Hello7\r\n"),
OneShot("Hello8\r\n"),
),
CLIENT = TCPClient("127.0.0.1", 2345),
SANITY_CHECK = ConsoleEchoer(),
linkages = {
("CLIENT_PROTOCOL","outbox"):("CLIENT","inbox"),
("CLIENT","outbox"):("SANITY_CHECK","inbox"),
}
).run()
With the reason being that it sidesteps the shutdown message issue by not
making those links.
The ideal way of dealing with this of course is to build either a component
that handles your client side protocol specifically, or an "expect" component
that allows for more interesting behaviour.
Michael.
--
http://yeoldeclue.com/blog
http://twitter.com/kamaelian
http://www.kamaelia.org/Home
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"kamaelia" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---