Chu Li wrote:
> In the manpage, there is such description " In each of the following
> redirections, if file is of the form /dev/sctp/host/port,
> /dev/tcp/host/port, or /dev/udp/host/port, where host is a hostname or host
> address,
> and port is a service given by name or an integer port number, then the
> redirection
> attempts to make a tcp, sctp or udp connection to the corresponding socket."
> But I don't know how to use /dev/sctp, /dev/udp or /dev/tcp in Redhat
> Linux, could you give some example?
-- snip --
# open TCP channel to the web server specified in ${host} and ${port}
redirect {netfd}<>"/dev/tcp/${host}/${port}" || { print -u "failure" ;
exit 1 ; }
# send HTTP "GET" request to retrive document ${path}
request="GET /${path} HTTP/1.0\n"
request+="Host: ${host}\n"
request+="User-Agent: osoldevconf2007bot (2007-01-26; $(uname -s -r
-p))\n"
print -- "${request}\n" >&${netfd}
# collect response and send it to stdout
cat <&${netfd}
# close connection
redirect {netfd}<&-
-- snip --
Some more networked demo code can be found at here (this stuff was
written for the OpenSolaris.org ksh93-integration project):
- tinyurl.com client:
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/scripts/shtinyurl.sh
- Client to read/write text blobs to pastebin.ca
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/scripts/shnote.sh
- rss reader:
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/scripts/rssread.sh
- IRC bot:
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/scripts/shircbot.sh
etc.
- Plain SCTP test:
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/scripts/test_net_sctp.sh
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users