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:
/* 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 */