/* t.c */ /* Linux: gcc -I... -L... -o t t.c -ltcl8.5 */ /* Windows: cl t.c /I c:/tcl/include c:/tcl/lib/tcl85.lib */ #include #include #ifndef __WIN32__ #include #endif #include /* just for demo */ void connection_callback(ClientData clientData, Tcl_Channel channel, char *hostName, int port){ } /* BFI exit */ void bfi_exitproc(ClientData clientData) { fprintf(stderr, "BFI exitproc...\n"); _exit(0); } int main() { Tcl_Channel server_channel; int port = 65432; /* TCL init */ Tcl_FindExecutable(NULL); /* open TCP server socket */ server_channel = Tcl_OpenTcpServer(NULL, port, NULL, connection_callback, NULL); /* set up the exit event in 1s */ Tcl_CreateTimerHandler(1000, bfi_exitproc, NULL); while (1) { #if 1 Tcl_DoOneEvent(TCL_ALL_EVENTS); #else Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); #endif } /* not reached */ return 0; } /* EOF */