Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <process.h>
- #include <string>
- struct MyData
- {
- std::string ip;
- std::string port;
- };
- unsigned int __stdcall ServerThread(void* param)
- {
- MyData* myData = (MyData*)param;
- // Daten gültig
- delete myData;
- return 0;
- }
- int main(int argc, char** argv)
- {
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2,2), &wsaData);
- std::ifstream file(argv[1]);
- std::string row;
- while(std::getline(file, row))
- {
- unsigned int pos = row.find(":");
- MyData* myData = new MyData;
- myData->ip = row.substr(0, pos);
- myData->port = row.substr(pos + 1);
- _beginthreadex(0, 0, ServerThread, myData, 0, 0); // CreateThread() hat ein leak
- }
- file.close();
- std::cin.get(); // Whatever
- }
Add Comment
Please, Sign In to add comment