Subject: Announce new EasySocket package makes using async sockets a snap - DN [1]
Mo <no@spam.com> - 09 Nov 1999 - comp.lang.tcl
Hi all. One of the most common postings to this list are questions about how to use the socket command. People are constantly asking for examples and pointers. I am going to try to address this by giving folks the EasySocket package I wrote for a client-server app. This package is an OO style class that provides async socket functionality without requiring that the user know all the details of the socket and fileevent commands. All that is required to use this package is to download the source code from my Tcl homepage. http://www.cs.umn.edu/~dejong/tcl/EasySocket.tar.gz http://www.cs.umn.edu/~dejong/tcl/EasySocket.zip The download includes documentation in the .help files as well as regression tests that ensure the code works as expected. All you need to do is extract the file into the lib directory of you Tcl installation. Here is a quick example that shows how to use the package. This example makes a socket connection to netscape's web server and downloads the webpage a line at a time. package require EasySocket Socket s -ready MsgReady proc MsgReady { msg } { puts "got msg \"$msg\" from server" } s connect www.netscape.com 80 s send "GET /\n" Here is a little bit more complex example that uses the FTP protocol to find out the size of a file on the Scriptics FTP server. Run these commands line by line inside wish to see the results. package require EasySocket Socket s -ready MsgReady proc MsgReady { msg } { puts "got msg \"$msg\" from server" # Check for size msg from the ftp server if {[lindex $msg 0] == 213} { global size set size [lindex $msg 1] } } s connect ftp.scriptics.com 21 s send "USER anonymous" s send "PASS no@addr.com" s send "CWD pub/tcl/java" s send "SIZE jaclSrc125.zip" s disconnect puts "file size is $size bytes" Later Mo DeJong
Last modified
1999-11-17
1999-11-17
(195.108.246.50)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
