example.c 771 B

12345678910111213141516171819202122232425262728293031
  1. #include <stdio.h>
  2. #include "fester.h"
  3. // on windows compile with -lws2_32
  4. int main() {
  5. struct client * storage;
  6. // does something dumb for Msft
  7. __STARTUP();
  8. // get a server socket from the Operating system
  9. int sock = setup();
  10. // allocate memory for storage for the life of the application
  11. if(NULL == (storage = allocateBunnies(sock))) {
  12. fprintf(stderr, "not enough memory for program to run\n");
  13. return 0;
  14. }
  15. /* run the main loop as often as possible, in this example there is
  16. * nothing else to do, so there is just an infinite loop where
  17. * normally a different program might do something else
  18. */
  19. while(1) {
  20. // technically this is a sleep, milliseconds is for how long
  21. somethingNeedDoing(1000 /* milliseconds */, storage);
  22. }
  23. }