Guest User

Untitled

a guest
Mar 6th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <process.h>
  2. #include <string>
  3.  
  4. struct MyData
  5. {
  6.     std::string ip;
  7.     std::string port;
  8. };
  9.  
  10. unsigned int __stdcall ServerThread(void* param)
  11. {
  12.     MyData* myData = (MyData*)param;
  13.  
  14.     // Daten gültig
  15.  
  16.     delete myData;
  17.  
  18.     return 0;
  19. }
  20.  
  21. int main(int argc, char** argv)
  22. {
  23.     WSADATA wsaData;
  24.     WSAStartup(MAKEWORD(2,2), &wsaData);
  25.  
  26.     std::ifstream file(argv[1]);
  27.     std::string row;
  28.  
  29.     while(std::getline(file, row))
  30.     {
  31.         unsigned int pos = row.find(":");
  32.  
  33.         MyData* myData = new MyData;
  34.  
  35.         myData->ip = row.substr(0, pos);
  36.         myData->port = row.substr(pos + 1);
  37.  
  38.         _beginthreadex(0, 0, ServerThread, myData, 0, 0); // CreateThread() hat ein leak
  39.     }
  40.  
  41.     file.close();
  42.  
  43.     std::cin.get(); // Whatever
  44. }
Add Comment
Please, Sign In to add comment