Hi guys, I'm new here and I'd like to ask some help from you.
Relatively I'm new to SFML too, I only used its "Audio" part a couple of years ago, and it worked like a charm (version 1.6).
Now I'm trying to learn the basics of networking, but I can't get it work.
First of all, I tried to run the pre-compiled "sockets.exe" in the examples folder of SFML 2.0, but it crashes after selecting from the 2 options (t/u, s/c).
Problem signature:
Problem Event Name: APPCRASH
Application Name: sockets.exe
Application Version: 0.0.0.0
Application Timestamp: 51613f31
Fault Module Name: libstdc++-6.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 4bc96cae
Exception Code: c0000005
Exception Offset: 000462f3
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1038
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
After this, I've found a simple example, but I can't compile it.
Project options:
Directories/Library Dir. F:/SFML-2.0/lib
Directories/Include Dir. F:/SFML-2.0/include
Parameters/Linker F:/SFML-2.0/lib/libsfml-network.a
The code itself:
#include <SFML/Network.hpp>
#include <string>
#include <iostream>
using namespace std;
int main()
{
sf::IpAddress ip = sf::IpAddress::getLocalAddress();
sf::TcpSocket socket;
char connectionType;
char mode;
char buffer[2000];
std::size_t received;
std::string text = "Connected to: ";
std::cout << "Enter (s) for Server, Enter (c) for client: " << std::endl;
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), received);
std::cout << buffer << std::endl;
system("pause");
return 0;
}
Error (Dev-Cpp 4.9.9.2):
In function `main': [Linker error] undefined reference to `_imp___ZN2sf4Time4ZeroE'
ld returned 1 exit status
[Build Error] [F:/Network_example/network.exe] Error 1
Error (Code::Blocks 13.12):
|=== Build: default in Network_example (compiler: GNU GCC Compiler) ===|
.objs\main.o:main.cpp|| undefined reference to `_imp___ZN2sf4Time4ZeroE'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
Thanks in advance for the help.
Greetings!