Attachment "socket.diff" to
ticket [936245ffff]
added by
davidw
2004-04-16 18:37:34.
Index: socket.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/socket.n,v
retrieving revision 1.9
diff -u -r1.9 socket.n
--- socket.n 15 May 2003 18:41:17 -0000 1.9
+++ socket.n 16 Apr 2004 11:19:00 -0000
@@ -47,7 +47,7 @@
this port. \fIPort\fR is an integer port number
(or service name, where supported and understood by the host operating
system) and \fIhost\fR
-is either a domain-style name such as \fBwww.sunlabs.com\fR or
+is either a domain-style name such as \fBwww.tcl.tk\fR or
a numerical IP address such as \fB127.0.0.1\fR.
Use \fIlocalhost\fR to refer to the host on which the command is invoked.
.PP
@@ -143,6 +143,30 @@
or bound. If the host name cannot be computed, the second element of the
list is identical to the address, its first element.
.PP
+.SH "EXAMPLES"
+
+A time server:
+
+.CS
+proc Server { channel clientaddr clientport } {
+ puts "Connection from $clientaddr registered"
+ puts $channel [clock format [clock seconds]]
+ close $channel
+}
+
+socket -server Server 9900
+vwait forever
+.CE
+
+And here is the corresponding client:
+
+.CS
+set server localhost
+set sk [socket $server 9900]
+gets $sk line
+close $sk
+puts "The time on $server is $line"
+.CE
.SH "SEE ALSO"
fconfigure(n), flush(n), open(n), read(n)