Hello, I'm trying to connct to my friend via hamachi, but the program doesn't connect us.
Here's the code, it's really simple but still doesn't work with hamachi. Localhost and enetring my hamachi IP on my computer works fine and hamachi worked in games (the dots are green).
#include <iostream>
#include <string>
#include <conio.h>
#include <SFML/Main.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Network.hpp>
int main()
{
sf::IpAddress IP;
sf::TcpSocket socket;
char connectionType, mode;
std::string text="Connected to ";
char message[1000];
std::size_t received;
std::cout << "Connection type (s) (c): ";
std::cin >> connectionType;
if (connectionType == 's')
{
sf::TcpListener listener;
listener.listen(2035);
listener.accept(socket);
std::cout << "SERVER SET" << std::endl;
text = text + "server";
}
else
{
std::cout << "IP: ";
std::cin >> IP;
socket.connect(IP, 2035);
std::cout << "CLIENT SET " << std::endl;
text = text + "client";
}
socket.send(text.c_str(), text.size() + 1);
socket.receive(message, sizeof(message), received);
std::cout << "MESSAGE: " << message;
_getch();
return 0;
}
Yes I'm kinda new to SFML, that's why I can't figure out why it doesn't work.