With my new code, if my server is overloaded and cannot accept a connection
immediately, my Windows client does not wait the whole timeout. This is the
behavior I want. I do not want it to be sitting there just in case my server
becomes available again or is on the process of being restarted.

My original code was behaving like this:

On UNIX:

1) Make a nonblocking connect call

2) I get EINPROGRESS

3) Do a select call that checks for writability of the socket [as man UNIX
documentation says]

4) The select returns BEFORE the timeout and getsockopt shows me an error of
ECONNREFUSED. [This is the behavior I want]

On Windows:

1) Make a nonblocking connect call

2) I get WSAEWOULDBLOCK

3) Do a select call that checks for writability of the socket [as MSDN
documentation says]

4) The select returns AFTER the timeout   [This is the behavior I did not
like because since my server is down I want my client to return immediately,
I do not care if the server is going to be restarted, or if it was
temporarily overloaded or else]


My new code changes step 3) in the Windows code to check for writability and
errorability by changing the following:

status = select(m_sock_fd+1, NULL, &WriteSet, NULL, &tv);

to this:

status = select(m_sock_fd+1, NULL, &WriteSet, &ErrorSet, &tv);


Now Windows and UNIX behave the same. When my server is down or overloaded,
the select call in the Windows client puts the socket in the ErrorSet and
returns immediately, calling the getsockopt show me an error of
WSAECONNREFUSED.


It is possible that the previous Windows behavior is correct but that is not
the behavior I want. I want the same behavior as UNIX which in my opinion is
what my clients would want. My clients can connect to a set of servers in a
raw, if one is not available for whatever reason I want them to move to the
next one instead of having to wait the whole timeout before trying the next
server.

Thanks for your help.

On Mon, Aug 24, 2009 at 6:47 PM, David Schwartz <dav...@webmaster.com>wrote:

>
> Md Lazreg wrote:
>
> > On UNIX the select will return after signaling the write set
> > [ as documented].
> > On Windows the select will return after signaling the _error_
> > set [The MSDN documentation says that you need to check the write set].
>
> That makes no sense.
>
> > My problem was that my select was checking only for write-ability
> > [which is what the documentation says for both Windows and UNIX].
> > So on Windows I was forced to timeout while on UNIX I was returning
> > immediately.
>
> Your code was correct.
>
> > Now I changed my select to check for both write-ability and
> > error-ability on Windows. Then I call getsockopt which returns
> > WSAECONNREFUSED as I have been expecting.
>
> That makes no sense. I'm glad it's working for you, but that doesn't make
> any sense.
>
> What does your code do now if the server is overloaded and cannot accept a
> connection immediately?
>
> DS
>
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
>

Reply via email to