Created
December 12, 2016 09:09
-
-
Save blippy/13ed17bd4ed84ea6c4ad5d49932749a1 to your computer and use it in GitHub Desktop.
Simple server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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