This is just the way TCP works, and SFML doesn't have any magic way around it.
When you want to connect to another system using TCP, it starts off with a SYN message, kind of like a "Hello, is anyone there?". Just like in real life, when you knock at someone's door, you don't know how long it takes them to answer you, or even if they are at home. Any sane person would give up waiting after several minutes if they have absolutely no clue whether the person is home or not. Conversely, knocking and assuming nobody is home after waiting for 2 seconds is also not the right thing to do.
For this reason, sf::TcpSocket::connect() takes a third parameter - the timeout value. This basically tells SFML how long you are willing to wait for the guy at the other end to answer your "Hello" message. Obviously, because we are talking about computer systems, you specify the value in milliseconds or microseconds typically. If you don't want to unnecessarily wait, you can set the amount of time you are willing to wait for, and when that time is exceeded, SFML will simply return from the connect() call unsuccessfully.
Now... if you are thinking of setting the timeout value to something really low, like... 0 or 1 millisecond, keep in mind that 0 is reserved to indicate "wait forever", and if you choose a value that is too small, you won't give the message enough time to travel through the network and the reply to travel back. If the average round-trip-time between you and the server is 50ms, then only waiting for 40ms before giving up will never allow you to connect. As such, you should choose this value carefully.