njPipes 027

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

njPipes 027

Ed Tomlinson
-----BEGIN PGP SIGNED MESSAGE-----

Hi,

If you have downloaded njpipes 027 please ensure the zip is 209261 bytes in
size.  If not you will have problems as three classes are missing or old.

Njpipes has progressed nicely with the last two releases.  Pipes like the
following now work:

- -- examples\tcptask.njp
- -- tcpip requestor sends random numbers to tcpserv1
- -- usage: java tcpreq1 <number>

pipe (tcpreq1 stall 60000 debug 0 )
   random {} !
   tcpclient localhost 1958 timeout 10000 linger 500 !
   console

- -- multistream tcpip server example

pipe (tcpserv1 stall 30000 end ? debug 0 )

   tcplisten 1958 timeout 20000 !
a: deal secondary ?          -- send work to task stage requesting work
b: faninany !
   elastic !                 -- buffer requests to so no deadlocks
 a: !
   copy !                    -- buffer work so no deadlocks
   tcptask 1 !               -- worker task 1
 b: ?
 a: !
   copy !
   tcptask 2 !               -- worker task 2...
 b: ?
 a: !
   copy !
   tcptask 3 !
 b:

import pipes.

options binary

class tcptask extends stage final

method run() public
   a = arg()
   do
      loop forever
         output(a)                       -- request some data
         peekto()                        -- wait for a conection
         callpipe (tcplog stall 15000 end ? debug 0 )
            *in0: !
            take first 1 !
         f: fanin !                      -- basic echo server...
            tcpdata timeout 10000 !
            elastic !
         f:
      end
   catch StageError
      rc = rc()
   end
exit(rc*(rc<>12))

- -----------------------------------

This may look a bit cryptic but what is does is fairly simple.  It sets up
a simple tcpip echo server what will serve three clients at once.  The
tcpserv1 pipe implements the server using the tcptask stage which starts a
tcplog pipe for each connection.  The tcpreq1 pipes sends requests to
the server.

Have fun,
Ed Tomlinson <[hidden email]> http://www.cam.org/~tomlins/njpipes.html
Montreal, Canada

To obtain my public key mail me with a subject of: PGP Key
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv

iQEVAwUBNUzm1zaYyP7siYcJAQFIRwf/UVM+6xmuAG0FJRflAA2wIde4bPne716e
GyoPXkly4dIcj2Uby2pkqGM4uhth0gBYKXokWQEwGkPFGD2XOfeD/0bMP0f+9QQn
INVRgU2R2wLqxszBmboze5TfKTwU3ya2Gq4hWGP/7N/IYf1fEcSpjnfxkS4skqzA
qEhb6uAr9E3mmNJHBGwGa0JNH3x7JpN1ylyvnCpsD+s0n7+2nnRFlFqA4sJkiBKR
SXgSLGiyCPNkUKYILUP5450VN16MJyHpyqoI9n60uXwvB5fRamz2v0VeTthRqdqd
YT9SIFjLy6FXtaz17s0ofSuVOgX7el7NAUtd1p6IkvKKjHvzuKljpA==
=TGp6
-----END PGP SIGNATURE-----


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>