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 #42549 is a reply to message #42396] Mon, 24 March 2014 08:22 Go to previous messageGo to previous message
steffen is currently offline  steffen
Messages: 38
Registered: May 2007
Location: Denmark
Member

Hi Mirek,

Thank you for the answer. I thought it might be complicated and I understand you concerns.
I have another suggestion then, that wont break anything:

Could you add a function that can be called prior to Connect, where one can determine if the socket should be blocking or not?
Storing a member variable containing either O_BLOCK or O_NONBLOCK and then use this variable in the SetupSocket function.

bool TcpSocket::SetupSocket()
{
#ifdef PLATFORM_WIN32
	connection_start = msecs();
	u_long arg = 1;
	if(ioctlsocket(socket, FIONBIO, &arg)) {
		SetSockError("ioctlsocket(FIO[N]BIO)");
		return false;
	}
#else
	#ifdef PLATFORM_BSD
		connection_start = msecs();
	#endif
	if(fcntl(socket, F_SETFL, (fcntl(socket, F_GETFL, 0) | O_NONBLOCK))) {
		SetSockError("fcntl(O_[NON]BLOCK)");
		return false;
	}
#endif
	return true;
}

Would be something like this:
bool TcpSocket::SetupSocket()
{
#ifdef PLATFORM_WIN32
	connection_start = msecs();
	u_long arg = 1;
	if(ioctlsocket(socket, mBlockingMode, &arg)) {
		SetSockError("ioctlsocket(FIO[N]BIO)");
		return false;
	}
#else
	#ifdef PLATFORM_BSD
		connection_start = msecs();
	#endif
	if(fcntl(socket, F_SETFL, (fcntl(socket, F_GETFL, 0) | mBlockingMode))) {
		SetSockError("fcntl(O_[NON]BLOCK)");
		return false;
	}
#endif
	return true;
}


As I wrote earlier, commenting out the O_NONBLOCK part also gives correct result.

Regards,
Steffen
 
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: Thu May 16 05:03:36 CEST 2024

Total time taken to generate the page: 0.02204 seconds