Announce: tkconnect - simple Tcp/ip client 
Author Message
 Announce: tkconnect - simple Tcp/ip client

tkconnect is a simple Tcl7.5/Tk4.1 Tcp/Ip multi connections,
multi windows client that can be usefull for MUDs, game servers,
debugging network, but mainly as an example/tutorial on using tcl/tk
networking and basic widgets.

Get it from

  http://www.*-*-*.com/ ~dl/softs.html

( or directly ftp://ftp.lyot.obspm.fr/tcl/tkconnect
  or http://www.*-*-*.com/ ~dl/tkconnect
  5kbytes with comments)

Regards
dl

--

** job hunting !** please see http://www.*-*-*.com/ ~dl/cv.html or mail me



Sun, 22 Nov 1998 03:00:00 GMT  
 Announce: tkconnect - simple Tcp/ip client

tkconnect is a simple Tcl7.5/Tk4.1 Tcp/Ip multi connections,
multi windows client that can be usefull for MUDs, game servers,
debugging network, but mainly as an example/tutorial on using tcl/tk
networking and basic widgets.

Get it from

  http://www.lyot.obspm.fr/~dl/softs.html

( or directly ftp://ftp.lyot.obspm.fr/tcl/tkconnect
  or http://www.lyot.obspm.fr/~dl/tkconnect
  5kbytes with comments)

Regards
dl

--


  Announcements archived at http:/www.xpi.com/tcl/comp.lang.tcl.announce/
  The primary Tcl/Tk archive is ftp://mirror.neosoft.com/pub/tcl/]]



Sun, 22 Nov 1998 03:00:00 GMT  
 Announce: tkconnect - simple Tcp/ip client

Here is the new version (still available from
http://www.lyot.obspm.fr/~dl/softs.html )

---cut---cut---
#! /bin/sh
# the next line restarts using wish4.1 \

#
# $Id: tkconnect,v 1.2 1996/06/11 12:07:48 dl Exp $
#
# Raw 'telnet' client (without telnet negotiation handling, line by line
# mode only). It includes a command history.
#
# This application is intended mainly as a tutorial/simple example
# of networking use with tcl7.5 and basic tk4.1 widgets...
#

#
# latest version on http://hplyot.obspm.fr/~dl/softs.html
#
# GNU General Public License - Author: Laurent Demailly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# $Log: tkconnect,v $
# Revision 1.2  1996/06/11  12:07:48  dl
# bug fix: wrong connect was sometime closed upond window delete of an already
#          closed connect.
#
# Revision 1.1  1996/06/05  18:16:25  dl
# Initial revision
#
#
#

# rcs kewords extraction
regexp {[.0-9]+} {$Revision: 1.2 $} version

# tk4 look fixup
  option add *highlightThickness 0
  option add *Button.Pad 1
  option add *Menubutton.Pad 2
  option add *Menu.BorderWidth 2
  option add *Menu.activeBorderWidth 1
  option add *Message.padX 5
  option add *Message.padY 2

#
# Proc handler, called when the peer 'says' something
#

proc handler {mode c n cmd} {
  global skip header;
# puts stderr "-called handler $mode,$c,$n-";
  if {[catch {read $c} res]} {
    puts stderr "-Error in reading : $res-";
    lappend cmd "\n-Error in reading : $res-\n";
    uplevel #0 $cmd;
    DoClose $n;
  } elseif {[string compare "" $res]} {
    puts -nonewline $res;
    lappend cmd $res;
    uplevel #0 $cmd;
    flush stdout;
  } else {
    puts stderr "-Connection Closed-";
    lappend cmd "\n-Connection Closed-\n";
    uplevel #0 $cmd;
    DoClose $n;
  }

Quote:
}

# make scroillable text widget
proc mkTxtWin {w} {
  frame $w
  text $w.msg -yscrollcommand "$w.scroll set" \
     -setgrid true -height 24 -width 80 -wrap word;
  scrollbar $w.scroll -command "$w.msg yview"
  pack $w.msg -side left -fill both -padx 6 -pady 4 -expand yes;
  pack $w.scroll -side right -fill y -padx 6 -pady 4 ;
  $w.msg configure -state disabled;

Quote:
}

# add some text to a text widget
proc addTxt {w txt} {

# allow changes
  $w.msg configure -state normal;

  $w.msg insert end $txt;

# keep only last N lines (300)
  $w.msg delete 1.0 end-300l;

# adjust view
  $w.msg yview -pickplace end-1c;

# prevent edit
  $w.msg configure -state disabled;

Quote:
}

proc DoClose {n} {
 global conn;
 puts "-closing $n/$conn($n,sock)-";
 if {[catch {close $conn($n,sock)} res]} {
   puts "-closing error:$res";
 }
 catch {unset conn($n,sock)}

Quote:
}

proc DoCloseW {w1 w2 n} {
 global conn;
 if {[string compare $w1 $w2] || (![info exist conn($n,sock)])} return;
 DoClose $n;

Quote:
}

proc Connect {host port} {
  global conn;
  set n [incr conn(n)] ;
  set w .c$n;
  toplevel $w;
  wm title $w "C$n: $host $port";

  bind $w <Destroy> "DoCloseW %W $w $n";

  #button $w.bq -text Quit -command terminate;
  #pack $w.bq

  mkTxtWin $w.f;
  pack $w.f -fill both -expand 1;

  # history init
  set conn($n,txt) $w.f;
  for {set i 0} {$i<50} {incr i} {
   set conn($n,hist,$i) "";
  }
  set conn($n,hist,i) 0;
  set conn($n,hist,n) 0;

  entry $w.e -textvariable conn($n,what) -width 80;
  pack $w.e
  bind $w.e <Return> "sendstuff $n";
  bind $w.e <Up>   "histmove $w.e $n 49";
  bind $w.e <Down> "histmove $w.e $n 1";
  focus $w.e;

  # connect to the host
  if {[catch {set sock [socket $host $port]} msg]} {
    addTxt $w.f "- Connect error on $host port $port : $msg -\n";
    catch {unset conn($n,sock)}
  } else {
    set conn($n,sock) $sock;

    addTxt $w.f "- Connected to $host $port -\n";

    # non blocking reads
    fconfigure $sock -blocking 0 ; # -translation binary;

    # call handler when there is something to read from server :
    fileevent $sock readable "handler r $sock $n {addTxt $w.f}";
#   puts "new conn $n ready / bound $w destroy for $sock...";
  }

Quote:
}

proc sendstuff {n} {
  global conn;
  set what $conn($n,what);
  set w    $conn($n,txt);
  set sock $conn($n,sock);
  addTxt $w "$what\n";

  if {[catch {puts $sock $what;flush $sock} res]} {
    puts "WRITE ERROR\[$n\]: $res";
    addTxt $w "-write error-";
  }

# history management
  set i $conn($n,hist,n);
  set conn($n,hist,$i) $what;
  set i [expr ($i+1)%50];
  set conn($n,hist,i) $i;
  set conn($n,hist,n) $i;

  set conn($n,what) {};

Quote:
}

proc histmove {w n move} {
  global conn;
  set what $conn($n,what);

  set i $conn($n,hist,i);
  set conn($n,hist,$i) $what;
  set i [expr ($i+$move)%50];
  set conn($n,hist,i) $i;

  set what $conn($n,hist,$i);
  set conn($n,what) $what;

  $w icursor end;

Quote:
}

# in case of errors:
proc bgerror {mess} {
global errorInfo;
puts stderr "BACKGROUND ERROR : $mess";
puts stderr "ERRORINFO: $errorInfo";
exit 1;

Quote:
}

# main interface

proc ConnUI {w} {

  catch {bind $w <Destroy> "";destroy $w}
  toplevel $w;
  wm title $w "Connect";

  frame $w.fh;
  label $w.fh.lh -text "Host:";
  entry $w.fh.host -width 30 -textvariable host;
  pack $w.fh.lh -side left;
  pack $w.fh.host -side right -fill x -expand 1 -padx 1m;

  frame $w.fp;
  label $w.fp.lp -text "Port:";
  entry $w.fp.port -width 6  -textvariable port;
  pack $w.fp.lp -side left;

  button $w.fp.b -text "New Connection" -command "Connect \$host \$port";
  pack $w.fp.b -side right -padx 1m;

  pack $w.fp.port -side right -fill x -expand 1 -padx 1m;

  bind $w.fh.host <Return> "focus $w.fp.port";
  bind $w.fp.port <Return> "$w.fp.b invoke";
  focus $w.fh.host;

  pack $w.fh $w.fp -fill both -expand 1 -padx 1m -pady 1m;

  bind $w.fp.b <3> "source [info script]";

  bind $w <Destroy> "exit";

Quote:
}

if ![info exists conn] {
  set conn(n) 0;

Quote:
}

wm withdraw .
ConnUI .conn;

puts "\n-sourced ok!-";
# EOF
---cut---cut---

regards
dl
--

** job hunting !** please see http://hplyot.obspm.fr/~dl/cv.html or mail me



Sat, 28 Nov 1998 03:00:00 GMT  
 Announce: tkconnect - simple Tcp/ip client

Anyone working on extending this?  For instance, I notice that if I don't
provide a port to TkConnect 1.2, I get an error and no connection.  But I
don't know what the default port is for telnet, so I have to go and try
to find it.  

I am sure there are other neat features, like a full active window where
you can do vi's, etc. that would be useful.
--

:s <URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
:s Unless explicitly stated to the contrary, nothing in this posting should
:s be construed as representing my employer's opinions.



Mon, 30 Nov 1998 03:00:00 GMT  
 Announce: tkconnect - simple Tcp/ip client

Hello,
I'm releasing for alpha test (ie ppl used to tcl/tk installation...)
the first preliminary version of a general purpose, extensible
multi protocol,... network client GUI with plugin capabilities.
The first available plugin (included) is an Irc client with the look &
feel of 'classical' ircII, I'm developping a Go Game Internet server client
too, I welcome new plugin developpers ! (and feedback, the API aren't
closed,...)

  http://www.lyot.obspm.fr/~dl/netplug.html

(it is based on my previous simple tkconnect)

Regards
dl
--

** job hunting !** please see http://hplyot.obspm.fr/~dl/cv.html or mail me



Wed, 09 Dec 1998 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. C5 - TCP/IP Client/Server and DirectX Questions

2. TCP/IP server & client in CW2xxxx

3. Interest in TCP/Ip Server & Client

4. Client - Server slow tcp/ip...

5. TCP/IP sockets code in REXX script (long) - client.CMD (1/1)

6. TCP/IP sockets code in REXX script (long) - client.CMD (0/1)

7. CLIENT (Windows 3.1 or 95 or NT) to MVS-CICS via TCP/IP or other gateway

8. TCP/IP client app with MF COBOL?

9. Need help with TCP/IP client access from Windows

10. TCP IP, client and server socket

11. How to program the simple tcp/ip connection?

12. ANNOUNCE: tclTCP+ (TCP/IP, inetd, timers for Tcl)

 

 
Powered by phpBB® Forum Software