summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-22 11:21:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-22 11:21:00 (GMT)
commit490b4bf1f8778fddb9814d30cdf2c4bd89d9581d (patch)
treecd198dc363de934042ae24b29a7b911ad4e7c580 /generic
parented80f025f6f87f144ee7b63931890efb4421ee78 (diff)
downloadtcl-490b4bf1f8778fddb9814d30cdf2c4bd89d9581d.zip
tcl-490b4bf1f8778fddb9814d30cdf2c4bd89d9581d.tar.gz
tcl-490b4bf1f8778fddb9814d30cdf2c4bd89d9581d.tar.bz2
Added stub entry for tip #456. Documentation and tests still missing. Doesn't conform to TIP yet.
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls11
-rw-r--r--generic/tclDecls.h8
-rw-r--r--generic/tclIOCmd.c15
-rw-r--r--generic/tclIOSock.c24
-rw-r--r--generic/tclStubInit.c1
5 files changed, 49 insertions, 10 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 574b49b..20c3f3e 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -2326,6 +2326,17 @@ declare 630 {
# ----- BASELINE -- FOR -- 8.6.0 ----- #
+# TIP #456
+declare 631 {
+ Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp, int port,
+ const char *host, int flags, Tcl_TcpAcceptProc *acceptProc,
+ ClientData callbackData)
+}
+
+# ----- BASELINE -- FOR -- 8.7.0 ----- #
+
+
+
##############################################################################
# Define the platform specific public Tcl interface. These functions are only
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index b022d3c..d1c1170 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -1816,6 +1816,11 @@ EXTERN int Tcl_FSUnloadFile(Tcl_Interp *interp,
EXTERN void Tcl_ZlibStreamSetCompressionDictionary(
Tcl_ZlibStream zhandle,
Tcl_Obj *compressionDictionaryObj);
+/* 631 */
+EXTERN Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp, int port,
+ const char *host, int flags,
+ Tcl_TcpAcceptProc *acceptProc,
+ ClientData callbackData);
typedef struct {
const struct TclPlatStubs *tclPlatStubs;
@@ -2482,6 +2487,7 @@ typedef struct TclStubs {
void * (*tcl_FindSymbol) (Tcl_Interp *interp, Tcl_LoadHandle handle, const char *symbol); /* 628 */
int (*tcl_FSUnloadFile) (Tcl_Interp *interp, Tcl_LoadHandle handlePtr); /* 629 */
void (*tcl_ZlibStreamSetCompressionDictionary) (Tcl_ZlibStream zhandle, Tcl_Obj *compressionDictionaryObj); /* 630 */
+ Tcl_Channel (*tcl_OpenTcpServerEx) (Tcl_Interp *interp, int port, const char *host, int flags, Tcl_TcpAcceptProc *acceptProc, ClientData callbackData); /* 631 */
} TclStubs;
extern const TclStubs *tclStubsPtr;
@@ -3774,6 +3780,8 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_FSUnloadFile) /* 629 */
#define Tcl_ZlibStreamSetCompressionDictionary \
(tclStubsPtr->tcl_ZlibStreamSetCompressionDictionary) /* 630 */
+#define Tcl_OpenTcpServerEx \
+ (tclStubsPtr->tcl_OpenTcpServerEx) /* 631 */
#endif /* defined(USE_TCL_STUBS) */
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 9dc8f07..883c6b7 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -1490,7 +1490,7 @@ Tcl_SocketObjCmd(
enum socketOptions {
SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER, SKT_REUSEPORT
};
- int optionIndex, a, server = 0, port, myport = 0, async = 0, reuseport = 0;
+ int optionIndex, a, server = 0, port, myport = 0, async = 0, flags = 0;
const char *host, *myaddr = NULL;
Tcl_Obj *script = NULL;
Tcl_Channel chan;
@@ -1557,9 +1557,9 @@ Tcl_SocketObjCmd(
}
script = objv[a];
break;
- case SKT_REUSEPORT:
- reuseport = 1;
- break;
+ case SKT_REUSEPORT:
+ flags |= 1;
+ break;
default:
Tcl_Panic("Tcl_SocketObjCmd: bad option index to SocketOptions");
}
@@ -1604,12 +1604,7 @@ Tcl_SocketObjCmd(
acceptCallbackPtr->script = script;
acceptCallbackPtr->interp = interp;
- /* Hint for Tcl_OpenTcpServer to set socket option REUSEPORT */
- if(reuseport) {
- port |= (1 << 16);
- }
-
- chan = Tcl_OpenTcpServer(interp, port, host, AcceptCallbackProc,
+ chan = Tcl_OpenTcpServerEx(interp, port, host, flags, AcceptCallbackProc,
acceptCallbackPtr);
if (chan == NULL) {
Tcl_DecrRefCount(script);
diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c
index 7ed751c..72a0b5a 100644
--- a/generic/tclIOSock.c
+++ b/generic/tclIOSock.c
@@ -283,6 +283,30 @@ TclCreateSocketAddress(
}
return 1;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_OpenTcpServer --
+ *
+ * Opens a TCP server socket and creates a channel around it.
+ *
+ * Results:
+ * The channel or NULL if failed. If an error occurred, an error message
+ * is left in the interp's result if interp is not NULL.
+ *
+ * Side effects:
+ * Opens a server socket and creates a new channel.
+ *
+ *----------------------------------------------------------------------
+ */
+Tcl_Channel Tcl_OpenTcpServer(Tcl_Interp *interp, int port,
+ const char *host, Tcl_TcpAcceptProc *acceptProc,
+ ClientData callbackData)
+{
+ return Tcl_OpenTcpServerEx(interp, port, host, 0, acceptProc, callbackData);
+}
+
/*
* Local Variables:
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 2f1bb8b..23da6dc 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -1416,6 +1416,7 @@ const TclStubs tclStubs = {
Tcl_FindSymbol, /* 628 */
Tcl_FSUnloadFile, /* 629 */
Tcl_ZlibStreamSetCompressionDictionary, /* 630 */
+ Tcl_OpenTcpServerEx, /* 631 */
};
/* !END!: Do not edit above this line. */