Version 5 of Simple Server/Client Sockets

Updated 2004-02-03 15:11:11

* Purpose: Demonstrate server and client socket handling.

  Availability: http://moogy.unstable.org:8080/simple.sockets.tar.gz

This package contains 2 Tcl scripts. One is the server and the other is the client. Simply run the server from a console or xterm and then run the client from another console/xterm.

The scripts are fairly well commented and should be as newbie friendly as can be. The client connects to the server and you then simply type anything and the server will reply by echoing back whatever you typed plus a count of the lines sent. You can exit the client side by typing 'exit' and the server will also exit at that time.


Besides server/client socket handling the script provides an example of handling input from stdin, the console or xterm you are running the script from.

From the client script itself:

 # assign our event handler for stdin
 fileevent stdin readable localHandler
 #
 # This is something not obvious for the newbie. Assigning an event
 # handler for stdin is same as any other File Descriptor or socket.
 # The only difference being that the socket was already created by
 # Tcl at startup as one of the default sockets and the name stdin
 # is simply the File Descriptor that Tcl created.

See also stdin and "client/server with fileevent"