test-socket-creation.c 591 B

123456789101112131415161718192021222324252627
  1. #include "../src/utils.h"
  2. int main(int argc, char *argv[])
  3. {
  4. struct nl_handle *h[1025];
  5. int i;
  6. h[0] = nl_handle_alloc();
  7. printf("Created handle with port 0x%x\n",
  8. nl_socket_get_local_port(h[0]));
  9. nl_handle_destroy(h[0]);
  10. h[0] = nl_handle_alloc();
  11. printf("Created handle with port 0x%x\n",
  12. nl_socket_get_local_port(h[0]));
  13. nl_handle_destroy(h[0]);
  14. for (i = 0; i < 1025; i++) {
  15. h[i] = nl_handle_alloc();
  16. if (h[i] == NULL)
  17. nl_perror("Unable to allocate socket");
  18. else
  19. printf("Created handle with port 0x%x\n",
  20. nl_socket_get_local_port(h[i]));
  21. }
  22. return 0;
  23. }