Tcl Source Code

Changes On Branch tip-427
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch tip-427 Excluding Merge-Ins

This is equivalent to a diff from 544df7aea5 to b689b115bd

2014-12-17
08:24
TIP-427: make "fconfigure $h -connecting" official (client sockets only) check-in: 9fcbf61071 user: oehhar tags: trunk
08:22
Documented "fconfigure $h -connecting" on socket man page Closed-Leaf check-in: b689b115bd user: oehhar tags: tip-427
07:53
Merge trunk check-in: bc38411db8 user: oehhar tags: tip-427
2014-12-15
10:23
merge trunk (but 86 -> 90) check-in: ba65c384d5 user: jan.nijtmans tags: novem
10:20
85 -> 86 check-in: 544df7aea5 user: jan.nijtmans tags: trunk
2014-12-14
12:13
merge-mark check-in: 975a47cdd7 user: jan.nijtmans tags: trunk

Changes to doc/socket.n.

93
94
95
96
97
98
99




100
101
102
103
104
105
106
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110







+
+
+
+







The Tcl event loop should be running while an asynchronous connection
is in progress, because it may have to do several connection attempts
in the background. Running the event loop also allows you to set up a
writable channel event on the socket to get notified when the
asynchronous connection has succeeded or failed. See the \fBvwait\fR
and the \fBchan\fR commands for more details on the event loop and
channel events.
.PP
The \fBchan configure\fR option \fB-connecting\fR may be used to check if the connect is still running. To verify a successful connect, the option \fB-error\fR may be checked when \fB-connecting\fR returned 0. 
.PP
Operation without the event queue requires at the moment calls to \fBchan configure\fR to advance the internal state machine. 
.RE
.SH "SERVER SOCKETS"
.PP
If the \fB\-server\fR option is specified then the new socket will be
a server that listens on the given \fIport\fR (either an integer or a
service name, where supported and understood by the host operating
system; if \fIport\fR is zero, the operating system will allocate a
182
183
184
185
186
187
188





189
190
191
192
193
194
195
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204







+
+
+
+
+







\fB\-peername\fR
.
This option is not supported by server sockets. For client and accepted
sockets, this option returns a list of three elements; these are the
address, the host name and the port to which the peer socket is connected
or bound. If the host name cannot be computed, the second element of the
list is identical to the address, its first element.
.RE
.TP
\fB\-connecting\fR
.
This option is not supported by server sockets. For client sockets, this option returns 1 if an asyncroneous connect is still in progress, 0 otherwise.
.PP
.SH "EXAMPLES"
.PP
Here is a very simple time server:
.PP
.CS
proc Server {startTime channel clientaddr clientport} {

Changes to unix/tclUnixSock.c.

901
902
903
904
905
906
907
908

909
910
911
912
913
914
915
901
902
903
904
905
906
907

908
909
910
911
912
913
914
915







-
+







                        "can't get sockname: %s", Tcl_PosixError(interp)));
            }
	    return TCL_ERROR;
	}
    }

    if (len > 0) {
	return Tcl_BadChannelOption(interp, optionName, "peername sockname");
	return Tcl_BadChannelOption(interp, optionName, "connecting peername sockname");
    }

    return TCL_OK;
}

/*
 *----------------------------------------------------------------------

Changes to win/tclWinSock.c.

1497
1498
1499
1500
1501
1502
1503
1504

1505
1506

1507
1508
1509
1510
1511
1512
1513
1497
1498
1499
1500
1501
1502
1503

1504
1505

1506
1507
1508
1509
1510
1511
1512
1513







-
+

-
+







	}
    }
#endif /*TCL_FEATURE_KEEPALIVE_NAGLE*/

    if (len > 0) {
#ifdef TCL_FEATURE_KEEPALIVE_NAGLE
	return Tcl_BadChannelOption(interp, optionName,
		"peername sockname keepalive nagle");
		"connecting peername sockname keepalive nagle");
#else
	return Tcl_BadChannelOption(interp, optionName, "peername sockname");
	return Tcl_BadChannelOption(interp, optionName, "connecting peername sockname");
#endif /*TCL_FEATURE_KEEPALIVE_NAGLE*/
    }

    return TCL_OK;
}

/*