Click here to Skip to main content
15,749,352 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to make a connection between two computers both of them are using tp-link adapter , but i'm not receving anything from client .

<pre lang="C++">
<pre>#include <iostream>
#include<SFML/Network.hpp>
using namespace std;
int main()
{
    string lolz;
    cout << "C[CLIENT]/S[SERVER] : ";
    cin >> lolz;
    
    if (lolz.compare("S") == 0)
    {
        sf::UdpSocket socket;
        socket.bind(55002);
        char buffer[1024];
        std::size_t received = 0;
        sf::IpAddress sender;
        unsigned short port;
        socket.receive(buffer, sizeof(buffer), received, sender, port);
        std::cout << sender << " CLIENT SEND YOU : : " << buffer << std::endl;
        std::string message = "From server : Response is [ok]" + sender.toString();
        socket.send(message.c_str(), message.size() + 1, sender, port);


    }
    else if (lolz.compare("C") == 0){
        string ipSer;
        cout << "SERVER IP : ";
        cin >> ipSer;
        sf::UdpSocket socket;
        socket.bind(55001);
        // Send a message to IP on port 55002
        std::string message = "FROM CLIENT : [ok]  " + sf::IpAddress::getLocalAddress().toString();
        socket.send(message.c_str(), message.size() + 1, ipSer, 55002);
        char buffer[1024];
        std::size_t received = 0;
        sf::IpAddress sender;
        unsigned short port;
        socket.receive(buffer, sizeof(buffer), received, sender, port);
        std::cout << sender << " SERVER SEND YOU : : " << buffer << std::endl;
    }
}




What I have tried:

i tried to turn off firewall , antivirus
changing the ports
....
Posted
Comments
Richard MacCutchan 26-Sep-22 15:31pm    
What IP address are you using to connect the two devices?
jeron1 26-Sep-22 17:20pm    
Verify that you're sending the proper data on the proper interface first. Wireshark is a great tool to see what's going on sending and receiving with your network ports.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900