Skip to content

Instantly share code, notes, and snippets.

@blippy
Created December 12, 2016 09:09
Show Gist options
  • Select an option

  • Save blippy/13ed17bd4ed84ea6c4ad5d49932749a1 to your computer and use it in GitHub Desktop.

Select an option

Save blippy/13ed17bd4ed84ea6c4ad5d49932749a1 to your computer and use it in GitHub Desktop.
Simple server
set i 0
proc accept {chan addr port} { ;# Make a proc to accept connections
global i
puts "$addr:$port says $i [gets $chan]" ;# Receive a string
puts $chan goodbye ;# Send a string
close $chan ;# Close the socket (automatically flushes)
set i [expr 1 + $i]
} ;#
socket -server accept 12345 ;# Create a server socket
vwait forever ;# Enter the event loop
# See also http://wiki.tcl.tk/15315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment