Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Entering IP address problem?  (Read 2112 times)

0 Members and 1 Guest are viewing this topic.

pangaea

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Entering IP address problem?
« on: August 04, 2013, 01:20:11 am »
I don't know. If I uncomment everything is fine. I tried getlocaladdress, localhost. Tried typing it different ways like without . Tried different methods.

Yet nothing seems to work.

A friend ran this code on his computer that uses linux. He said it worked fine and connected. It might be firewall, but I disabled it and still get the same problem.  I'm doing this over wifi so that might be blocking it. However, that wouldn't explain why it works when I uncomment it. 

#include <SFML\Network.hpp>
#include <iostream>
#include <string>
#include <map>
#include <conio.h>

int main()
{
        std::string text = "Connected to: ";
        std::string sIP;
        unsigned short serverport = 2000;

        sf::TcpSocket socket;

        std::cout<<"Enter server ip: ";
        std::getline(std::cin, sIP);

        sf::IpAddress ip(sIP);

        socket.connect(sIP, serverport);

        //sf::IpAddress ip = sf::IpAddress::getLocalAddress();
        //socket.connect(ip, serverport);

        system("pause");

        return 0;
}
 
« Last Edit: August 04, 2013, 10:52:07 am by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Entering IP address problem?
« Reply #1 on: August 04, 2013, 10:52:47 am »
What about

sf::IpAddress ip;
std::cin >> ip;

?
Laurent Gomila - SFML developer

pangaea

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Entering IP address problem?
« Reply #2 on: August 04, 2013, 12:53:38 pm »
That works. Thank you.