Overview
| Artifact ID: | d0381d8f7faa663bb1d98b601f6905140b874122 |
|---|---|
| Ticket: | 3574493fffffffffffffffffffffffffffffffff |
| Date: | 2012-10-04 22:06:21 |
| User: | ralfixx |
| Artifact Attached: | c11098daf670609d6ff2032bc3c6191b5adbbbf9 |
| Filename: | t.c |
| Description: | C source code |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49/* 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 <tcl.h> #include <stdio.h> #ifndef __WIN32__ #include <unistd.h> #endif #include <stdlib.h> /* 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 */