1
Network / 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:
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?
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;
}
#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?