While that makes sense, and is how I was doing it originally, it does require 
issuing the connect() call twice, once before the select(), and once afterwards.

-Carl


> On Jun 27, 2017, at 8:22 AM, [email protected] wrote:
> 
> If the socket says it's ready to read or write, then I would read or write 
> whatever you planned on reading or writing, but be prepared to handle an 
> error.  I think you will find that more robust than looking for particular 
> errors at particular times.
> 
>  
>  
> On 2017-06-26 15:52, Carl Hoefs wrote:
> 
>> 
>>> On Jun 26, 2017, at 3:37 PM, Dado Colussi <[email protected] 
>>> <mailto:[email protected]>> wrote:
>>> After the connect() returns EINPROGRESS, and after the select() indicates 1 
>>> descriptor ready for write, getsockopt() returns status=0, errno=0:
>>>  
>>>              status = getsockopt(sockfd,SOL_SOCKET,SO_ERROR,&error,&len);
>>>  
>>>  
>>> getsockopt() returns 0 on successful retrieval of the option value. So 
>>> that's good.
>>>  
>>> The option value is stored in memory pointed to by the fourth parameter 
>>> (named 'error', above). Hence the variable error == ECONNREFUSED.
>> 
>> Yes, it does indeed return ECONNREFUSED, errno = 61, "Interrupted system 
>> call" into my error variable! (I thought it would also set errno, but it 
>> doesn't.)
>>  
>> Thanks; this is exactly what I was looking for!
>>  
>> -Carl
>>  
>>  
>> 
>> 
>>  _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Macnetworkprog mailing list      ([email protected] 
>> <mailto:[email protected]>)
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/macnetworkprog/tim%40ivisit.com 
>> <https://lists.apple.com/mailman/options/macnetworkprog/tim%40ivisit.com>
>> 
>> This email sent to [email protected] <mailto:[email protected]>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to