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

Author Topic: TcpSocket::connect difficulty  (Read 1656 times)

0 Members and 1 Guest are viewing this topic.

dampersand

  • Newbie
  • *
  • Posts: 2
    • View Profile
TcpSocket::connect difficulty
« on: April 19, 2013, 10:54:15 am »
Hi,

I've been fooling around with SFML 2.0's networking module for the last couple of hours, and I've run up against something that's causing me some grief.

I'm building a very simple port checker based on a gentleman's code at cplusplus.com, but I'm having a hangup every time I use TcpSocket::connect.  I've got the following:

#include <SFML/Network.hpp>
#include <iostream>
#include <string>


bool openPort(const std::string& IPadd, int portNum)
{
    sf::TcpSocket Socketss;
    bool open = (Socketss.connect(sf::IpAddress(IPadd), portNum) == sf::Socket::Done);
    Socketss.disconnect();
    return(open);
}

int main()
{
        int port=80;
        std::string address="localhost";
        if (openPort(address, port))
            std::cout << "Port is open." << std::endl;
        else
            std::cout << "Port is closed." << std::endl;

        return 0;
}

Now, she throws no exceptions or anything, builds with no errors; I merely get that sweet little "YourProgram.exe has stopped working" message from Windows.  I've narrowed it down to the 'connect' line, such that the following program recreates the same error:

 
#include <SFML/Network.hpp>
   
int main()
{
    sf::TcpSocket Socketss;
    Socketss.connect(sf::IpAddress(127, 0, 0, 1), 80);

    return(0);
}

I've double- and triple-checked my compiler, made sure I've got the .dlls in my directory, the libraries are all properly pointed to, and all those other damn-fool mistakes I've made in the past are nowhere to be seen (which means I'm making a new damn-fool mistake).

Thoughts?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: TcpSocket::connect difficulty
« Reply #1 on: April 19, 2013, 11:02:40 am »
Which SFML 2.0 package are you using? You probably need to recompile it, or get a nightly build ('General discussions' forum), the precompiled 2.0 RC is not compatible with gcc 4.7, which is now used a lot.
Laurent Gomila - SFML developer

dampersand

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: TcpSocket::connect difficulty
« Reply #2 on: April 19, 2013, 07:28:01 pm »
I'm using the win32 GCC SJLJ package - and yeah, that'd probably be the issue; I've got the precompiled version and my compiler is gcc 4.7.1.  How did I miss that it was incompatible with gcc 4.7?

There I go, not doing my research. :/

Edit: Also, thank you! :)