Loading file crashing game?

I've been making a multilayer game for a while and have a config that the game loads for the IP and stuff. I just recently put all the loading stuff into a function just so its easier to go through the code, but now the game isn't really working. It works fine on my computer connecting to the server myself, but when someone else tries to do it it seems like the game is working like it says the IP and everything from the config. When it tries to connect it either doesn't work or crashes just saying the program stopped working. Here is the code... I don't know if this is what is causing it to not work or something else.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
string LoadConfig(int &loadPort, bool &fullscreen) {
	string file;
	string loadIP;
	vector<string> fileLines;
	fstream config("config.txt");
	if (config.good()) {
		while (!config.eof()) {
			getline(config, file);
			//cout << file << endl;
			fileLines.push_back(file);
		}
		config.close();
	}
	else {
		cout << "Unable to find file..." << endl;
		cout << "Created config file. Enter information into config and restart" << endl;
		ofstream config;
		config.open ("config.txt");
		config << "IP:123.123.123.123:\n";
		config << "Port:12345:\n";
		config << "Fullscreen:0:\n";
		config.close();
		cout << "Press any key to exit..." << endl;
		system("pause>nul");
		exit(EXIT_FAILURE);
	}
	
	int fileLine = 0;
	for (unsigned int i = 0; i < fileLines.size(); i++) {
		istringstream ss(fileLines[i]);
		string token;
		int filePlace = 0;

		while(getline(ss, token, ':')) {
			if (filePlace == 1) {
				if (fileLine == 0)
					loadIP = token;
				else if (fileLine == 1)
					loadPort = atoi(token.c_str());
				else if (fileLine == 2)
					fullscreen = atoi(token.c_str());
			}
			filePlace++;
		}
		fileLine++;
	}
	cout << "IP: " << loadIP << " Port: " << loadPort << " Fullscreen: " << fullscreen << endl;
	return loadIP;
}
I assume that line 47 is printing out the right IP and port?

Are you sure that the other computers can access the server? If you're using a home server with an address of 192.168.1.x or 10.x.x.x then the IP address is not visible to the internet at large. Your router performs network address translation to let you talk to the internet.
Yes everything is port forwarded and working until I put loading into the function. I think a long time ago I had sorta a problem like this where it wouldn't save the file or something but I don't know, and yes it is just printing the IP and port from the config, which works.
Nothing wrong with the code? I don't really remember how I made it. Like don't really know what filePlace was there for.
Topic archived. No new replies allowed.