Trouble with SFML Networking

So guys,i was following tutorial on YT and i tried its code,it doesn't work,i don't know why,here it is:
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <iostream>
#include <string>
#include <conio.h>
#include<SFML/Network/IpAddress.hpp>

using namespace std;

int main()
{
	sf::IpAddress ip=sf::IpAddress::getLocalAddress();
	sf::TcpSocket socket;
	char ConnectionType,mode;
	char Buffer[2000];
	size_t recieved;
	string text="Connected to: ";

	cout<<"Enter S for server and C for Client\n";
	cin>>ConnectionType;

	if(ConnectionType=='s')
	{
		sf::TcpListener listener;
		listener.listen(2000);
		listener.accept(socket);
		text+="Server";
	}
	else if(ConnectionType='c')
	{
		socket.connect(ip,2000);
		text+="Client";
	}

	socket.send(text.c_str(),text.length()+1);
	socket.receive(Buffer,sizeof(Buffer),recieved);

	cout<<Buffer<<endl;
	bool done=false;
	while(!done)
	{
		if(mode=='s')
		{
			getline(cin,text);
			socket.send(text.c_str(),text.length()+1);
			mode='r';
		}
		else if(mode=='r')
		{
		    socket.receive(Buffer,sizeof(Buffer),recieved);

			if(recieved>0)
			{
			    cout<<"Received:"<<endl;
			    mode='s';
			}

		}
	}
	system("PAUSE");

	return 0;
}
Last edited on
Could you post your errors please
http://scr.hu/5q0t/f5nm8
I've took screenshot,since list of errors is too long
They look like linking errors. Try following the tutorials on the sfml website http://www.sfml-dev.org/tutorials/2.3/ It is regularly brought up in the forums that when people follow online video tutorials, they tend to go wrong as most of the video tutorials are wrong in some way. If you follow the tutorial about setting up sfml with whatever IDE you are using on the page I linked exactly, then it should get rid of the linking errors. You also need to convert your = on line 30 to a ==.
Oh,thanks!
Topic archived. No new replies allowed.