Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » [SOLVED] TcpSocket Connect error
Re: TcpSocket Connect error [message #42415 is a reply to message #42396] Wed, 12 March 2014 10:52 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
steffen wrote on Tue, 11 March 2014 07:35

Hi,

Newest uppsrc revision 7033.

Here on my Ubuntu 12.04 workstation I see a problem with TcpSocket.Connect, it always returns true, even if no server is listening at the other end:

TcpSocket client_socket;
client_socket.Timeout(5000);
if (client_socket.Connect("127.0.0.1", 12345)) // Connect to non existing server
{
	LOG("ERROR, Connect returned true");
}
else
{
	LOG("Correct, The connection could not be established");
}

The doc mentions the operation is blocking, but it is not. It does not say anything about the return value, I just assume it would be true on success.

It works if I comment the O_NONBLOCK from Socket.cpp->TcpSocket::SetupSocket(), like this:
if(fcntl(socket, F_SETFL, (fcntl(socket, F_GETFL, 0)/* | O_NONBLOCK*/))) {

I discovered this while trying to connect to a slow server and the not so reader friendly TcpSocket::RawConnect function passed on the SOCKERR(EINPROGRESS) check. No matter if a connection was established or not.

I don't have the in depth knowledge on the upp code base, to say if removing the O_NONBLOCK will cause undesired problems in other places.




The documentation is misleading. It is only blocking w.r.t. DNS resolve.

[Updated on: Wed, 12 March 2014 10:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SSL handshake error
Next Topic: How to use Skylark on external server
Goto Forum:
  


Current Time: Wed May 15 11:31:18 CEST 2024

Total time taken to generate the page: 0.02221 seconds