fork download
  1. #include <stdio.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <functional>
  5. #include <thread>
  6. #include <iostream>
  7.  
  8.  
  9.  
  10. class tcp_server
  11. {
  12. private:
  13. public:
  14. tcp_server(){}
  15. ~tcp_server(){}
  16. void create_thread(int my_socket)
  17. {
  18. // auto f = std::bind(&tcp_server::funkcja,my_socket);
  19. auto f2 = [this](int my_sock){funkcja(my_sock);};
  20. std::thread t(f2, my_socket);
  21. t.detach();
  22. }
  23.  
  24. void funkcja(int my_socket)
  25. {
  26. std::cout<<my_socket;
  27.  
  28. }
  29. };
  30.  
  31.  
  32. int main(void) {
  33.  
  34.  
  35. tcp_server s;
  36.  
  37. s.create_thread(4);
  38. return 0;
  39. }
Success #stdin #stdout 0s 11656KB
stdin
Standard input is empty
stdout
Standard output is empty