Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. void networking::TCP_Server::acceptConnection() {
  2. std::string stringToSend{"This is a test string to be replied to"};
  3. int new_fd = accept(listeningFD, nullptr, nullptr);
  4. send(new_fd, stringToSend.c_str(), stringToSend.size(), 0);
  5. sleep(3);
  6. std::cout << ("End of thread");
  7.  
  8. }
  9.  
  10. ///LISTEN FOR CONNECTIONS ON listeningFD
  11. ///CREATE A LIST OF FILE DESCRIPTORS FOR POLL fds[]
  12.  
  13.  
  14. (fds[i].fd == listeningFD) {
  15.  
  16. do {
  17. std::cout << ("New incoming connection - %dn", new_fd);
  18. std::async(std::launch::async, acceptConnection)
  19.  
  20. } while (new_fd != -1);
  21.  
  22.  
  23. } /* End of existing connection is readable */
  24. } /* End of loop through pollable descriptors */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement