Tcl Source Code

Artifact [c11098daf6]
Login

Artifact c11098daf670609d6ff2032bc3c6191b5adbbbf9:

Attachment "t.c" to ticket [3574493fff] added by ralfixx 2012-10-04 22:06:21.
/* 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 */