From - Thu Mar 26 09:45:06 1998
Path: nntpd.lkg.dec.com!pa.dec.com!decwrl!www.nntp.primenet.com!globalcenter0!news.primenet.com!nntp.primenet.com!news-out.internetmci.com!newsfeed.internetmci.com!128.230.129.106!news.maxwell.syr.edu!fu-berlin.de!newsfeed.dpn.de!news-out1.du.gtn.com!news-in2.du.gtn.com!news-in1.ne.gtn.com!news.westend.com!bluepeak.westend.com!news
From: Andreas Kupries <a.kupries@westend.com>
Newsgroups: comp.lang.tcl
Subject: Re: Client/Server Example?
Date: 24 Mar 1998 18:50:33 +0100
Organization: Me, myself and I
Lines: 83
Message-ID: <m3emzs9dw6.fsf@bluepeak.westend.com>
References: <3516BA62.8E9A22C4@compmore.net>
NNTP-Posting-Host: kupries.westend.com
X-Newsreader: Gnus v5.3/Emacs 19.34
Xref: nntpd.lkg.dec.com comp.lang.tcl:83061


John Hoffmann <support@compmore.net> writes:
> 
> I remember reading a couple months ago about a client/server example.

Is it the one attached to this post ?

> What I want to do is just transfer files from one server to another for
> a remote Apache configuration program.
> 
> http://www.gdiweb.com/images/apacheconf.gif
> 
> Can anyone point me in the right direction?

-------------------------------------------------------------------------------
#!/usr/local/bin/wish
# fileevent example
# (data coming a from a socket is displayed in a text widget)
# no luxuries (like scrollbars)

socket -server on_connect 18018

proc on_connect {newsock clientAddress clientPort} {
    fconfigure $newsock -blocking 0
    fileevent  $newsock readable [list handleInput $newsock]
}

proc handleInput {f} {
    # delete handler if input was exhausted.
    if {[eof $f]} {
	fileevent $f readable {}
	close     $f

	# closing application too, although not required
	after 5000 exit
	return
    }

    set data [read $f]

    if {[string length $data] > 0} {
	.t insert end $data
    }
}


text .t -bd 3 -relief sunken -bg yellow -fg red -width 80 -height 30
pack .t -side top -fill both -expand 1
-------------------------------------------------------------------------------
#!/usr/local/bin/tclsh
# generate characters and send them to a socket
# use after to make it slower for demonstration purposes
# disable buffering to remove the need for 'flush'

set    time  100
set    fname [info script]

set    fh    [open $fname r]
set    data  [read $fh]
close $fh

set         data [split $data {}]
set         out  [socket -async localhost 18018]
fconfigure $out -buffering none

foreach x $data {
    puts -nonewline $out $x
    after $time
}

close $out
exit
-------------------------------------------------------------------------------
#!/bin/sh
fe &
sleep 2
fe_drive

-- 
Sincerely,
	Andreas Kupries <a.kupries@westend.com>
			<http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------
