Henri,

You say that checking errno isn't safe in a multithreaded env (which would
certainly makes sense to me, since it looks like a global var).

However, after searching online, and reading up in "Programming Threads", by
Kleiman, Shah and Smaalders, I find on p. 47:

"Each thread has its own independent version of the errno variable.  This
allows different threads to make system calls that may change the value of
errno without interfering with each other."

They are describing Posix threads.  "errno" is actually a macro, apparently,
which accesses the correct, thread-specific errno variable.

Now, I am the first to admit that I don't understand all the weird
intersections between threads and sockets in C, but this looks to me like
checking errno against ECONNRESET may be fine.

Are there platforms where that's not true? 

The nice thing about getting that ECONNRESET error, is it lets us go ahead
and close out that connection, and try another one.  We could even close out
a whole cache of connections, which would most likely be the right thing to
do.  If we loop/retry, than how do we know to close the connection?

-Dan

GOMEZ Henri wrote:
> 
> >Okay so this means, you would prefer my proposed solution #1?
> >That was my inclination too.
> 
> Proposed solution #1 without the errno check.
> 
> My idea :
> 
> get the service code in a loop
> 
> for (i = 0; i < RETRIES; i++) {
> 
>         if (send_request() < 0)
>                 continue;
> 
>         if (read_reply() == 0)
>                 break;
> }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]

-- 

Dan Milstein // [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to