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 |
|
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
|
|
|
|
|
[SOLVED] TcpSocket Connect error
By: steffen on Tue, 11 March 2014 12:35
|
|
|
Re: TcpSocket Connect error
By: mirek on Wed, 12 March 2014 10:52
|
|
|
Re: TcpSocket Connect error
By: steffen on Wed, 12 March 2014 17:24
|
|
|
Re: TcpSocket Connect error
By: mirek on Wed, 12 March 2014 19:07
|
|
|
Re: TcpSocket Connect error
By: steffen on Thu, 13 March 2014 08:28
|
|
|
Re: TcpSocket Connect error
By: steffen on Thu, 13 March 2014 08:43
|
|
|
Re: TcpSocket Connect error
By: mirek on Sun, 23 March 2014 17:16
|
|
|
Re: TcpSocket Connect error
By: steffen on Mon, 24 March 2014 08:22
|
|
|
Re: TcpSocket Connect error
By: mirek on Mon, 24 March 2014 10:21
|
|
|
Re: TcpSocket Connect error
By: steffen on Mon, 24 March 2014 12:02
|
|
|
Re: TcpSocket Connect error
By: mirek on Tue, 01 April 2014 19:51
|
|
|
Re: TcpSocket Connect error
By: steffen on Wed, 02 April 2014 07:02
|
Goto Forum:
Current Time: Thu May 16 05:03:36 CEST 2024
Total time taken to generate the page: 0.02204 seconds
|