46
Network / Bug in sf::SocketTCP::Connect()
« on: July 10, 2009, 12:21:45 am »
Hi,
I've discovered a bug in the Connect() function of the sf::SocketTCP class on Linux.
Steps to reproduce:
- Create an instance of sf::SocketTCP.
- Connect to a host and port where no socket is listening.
- Provide a timeout!
Connect() returns sf::Socket::Done even if the connection couldn't be made. This results in a broken pipe later when trying to receive or send from/to the socket.
Example code:
SFML version: SVN (not latest trunk)
OS: Debian GNU/Linux Squeeze (Testing), kernel 2.6.26
I've discovered a bug in the Connect() function of the sf::SocketTCP class on Linux.
Steps to reproduce:
- Create an instance of sf::SocketTCP.
- Connect to a host and port where no socket is listening.
- Provide a timeout!
Connect() returns sf::Socket::Done even if the connection couldn't be made. This results in a broken pipe later when trying to receive or send from/to the socket.
Example code:
Code: [Select]
#include <iostream>
#include <SFML/Network.hpp>
int main( void ) {
sf::SocketTCP socket;
if( socket.Connect( 33033, "localhost", 2.f ) == sf::Socket::Done ) {
std::cout << "Connected. Sending data..." << std::endl;
socket.Send( "Foobar", 6 );
}
else {
std::cout << "Failed to connect." << std::endl;
}
return 0;
}
SFML version: SVN (not latest trunk)
OS: Debian GNU/Linux Squeeze (Testing), kernel 2.6.26