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

Author Topic: Bug in sf::SocketTCP::Connect()  (Read 5763 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
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:
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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Bug in sf::SocketTCP::Connect()
« Reply #1 on: July 10, 2009, 07:41:19 am »
Quote
SFML version: SVN (not latest trunk)

Which revision?
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Bug in sf::SocketTCP::Connect()
« Reply #2 on: July 11, 2009, 12:46:13 am »
I've just updated to the latest revision (r1165). The bug is still present.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Bug in sf::SocketTCP::Connect()
« Reply #3 on: July 11, 2009, 01:55:52 pm »
Ok, I'll try to fix this as soon as possible.

Thanks for your feedback :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Bug in sf::SocketTCP::Connect()
« Reply #4 on: July 12, 2009, 02:19:35 pm »
It's fixed, thanks for your help ;)
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Bug in sf::SocketTCP::Connect()
« Reply #5 on: July 12, 2009, 03:01:42 pm »
No problem, and thanks for the fast fix. :)

Edit: Confirmed from my side. Works flawlessly. :)