[Pharo-project] [Pharo-users] SocketStream persistence
Mariano Martinez Peck
marianopeck at gmail.com
Thu Nov 11 05:00:06 CET 2010
On Wed, Nov 10, 2010 at 3:09 PM, Daniel Klein <danielk at danielk.us> wrote:
> I just discoverd the 'noTimeout' message in the 'configuration' protocol,
> so that solves my persistence problem.
> But the question remains: When this process is running, it blocks until it
> completes. How can I fire it up so that I can continue to interact with
> Pharo while it is running?
> *From:* pharo-users-bounces at lists.gforge.inria.fr [mailto:
> pharo-users-bounces at lists.gforge.inria.fr] *On Behalf Of *Daniel Klein
> *Sent:* Tuesday, November 09, 2010 22:41
> *To:* 'A friendly place where any question about pharo is welcome'
> *Subject:* [Pharo-users] SocketStream persistence
> For my first real Pharo task I need to communicate with a server over
> telnet. As a proof of concept I cobbled this code into a workspace without
> regard for OO-anything (the hostname/login/password have been changed to
> protect the innocent ;-)
> | wire answer |
> wire := SocketStream openConnectionToHostNamed: 'myhost' port: 23.
> wire upToAll: 'login: '.
> wire nextPutAll: 'testlogin'; cr; flush.
> wire upToAll: 'Password: '.
> wire nextPutAll: 'dummypassword'; cr; flush.
> wire upToAll: '>'.
> wire nextPutAll: 'dbl'; cr; flush.
> wire upToAll: '?'.
> wire nextPutAll: '12'; cr; flush.
> wire upTo: Character lf.
> answer := Integer readFromString: (wire upTo: (Character value: 3)).
> wire upToAll: 'C:\home>'.
> wire nextPutAll: 'exit'. "close gracefully"
> ensure: [wire close].
> ^ answer
> on: ConnectionClosed
> do: [:ex | Transcript show: ex asString;cr. ex resume].
> The server process, dbl, is a simple C program that takes a number, n, as
> input and returns n*2. I'm using character 3 to indicate the end of the
> output sent back from the C program.
> This all works great and I get the expected answer of '24'.
> So, the next step was to simulate the server process taking a while to
> complete and then send back some form of acknowledgement. So I put a 'sleep
> 5 minutes' in the server process just prior to sending back the answer. The
> problem is that I then get a 'ConnectionTimedOut' error after about 45-50
> seconds. If I change the 'on:' line to:
> on: ConnectionClosed, ConnectionTimedOut
> then this errors out with 'IllegalResumeAttempt'.
> How can I keep the connection alive while the server is 'busy'?
> As an aside, while Pharo is processing the above code, I can't do anything
> else until it either completes or errors out. I thought Pharo used 'green
> I'm using:
> Latest update: #11414
> on Windows XP Pro.
> Pharo-users mailing list
> Pharo-users at lists.gforge.inria.fr
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-project