zsh-users
 help / color / mirror / code / Atom feed
From: "S. Cowles" <scowles@ckhb.org>
To: zsh-users@sunsite.dk
Cc: Peter Stephenson <pws@csr.com>
Subject: Re: zsocket help
Date: Wed, 26 Sep 2007 08:01:25 -0700 (PDT)	[thread overview]
Message-ID: <alpine.OSX.0.999.0709260759190.13930@ckhb04.ckhb.org> (raw)
In-Reply-To: <200709260848.l8Q8m2BF030743@news01.csr.com>


thank you very much, peter.  and, yes, i _do_ have a purchased copy of 
your superb book.  cheers, sir.
sid


On Wed, 26 Sep 2007, Peter Stephenson wrote:

> Date: Wed, 26 Sep 2007 09:48:02 +0100
> From: Peter Stephenson <pws@csr.com>
> To: zsh-users@sunsite.dk
> Subject: Re: zsocket help
> 
> "S. Cowles" wrote:
>> does anyone have a piece of sample code showing practical usage of
>> zsockets?  i'm not having success developing functioning zsocket code
>> using a current zsh cvs code pull.  i've been working from the zshall man
>> page and from the partial zsocket examples from zshlovers without success.
>> any help would be appreciated.  thanks.
>
> I got the following to work.
>
> In terminal A:
>
>  % typeset REPLY
>  % zmodload zsh/net/socket
>  % zsocket -l /tmp/zsocket
>  % print $REPLY
>  11
>  % zsocket -a 11
>
> This now blocks.  (I put the "typeset REPLY" at the start to ensure REPLY is
> created as a string, as you would naturally do in a function.)
>
> In terminal B:
>
>  % typeset REPLY
>  % zmodload zsh/net/socket
>  % zsocket /tmp/zsocket
>  % print $REPLY
>  3
>
> Terminal A returns at this point and I did:
>
>  % print $REPLY
>  3
>  % read -u3 && print $REPLY
>
> and in terminal B:
>
>  % print -u3 This is a message on the socket
>
> which produces in terminal A:
>
>  This is a message on the socket
>
> As far as I can see there's no way of closing the file descriptors using
> zsocket, which seems an omission.  Presumably you can use "exec 3>&-"
> etc. although to close a file descriptor over 9 you need to do something
> like:
>
>  % fd=11
>  % exec {fd}>&-
>
> --
> Peter Stephenson <pws@csr.com>                  Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070
>



      reply	other threads:[~2007-09-26 15:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-24  5:04 _values and specifying -M to compadd Danek Duvall
2007-09-24  9:24 ` Peter Stephenson
2007-09-24 15:36   ` Danek Duvall
2007-09-26  7:24   ` zsocket help S. Cowles
2007-09-26  8:48     ` Peter Stephenson
2007-09-26 15:01       ` S. Cowles [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.0.999.0709260759190.13930@ckhb04.ckhb.org \
    --to=scowles@ckhb.org \
    --cc=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).