[Vortex] How to tell whether a connection closed successfully?

Francis Brosnan Blazquez francis at aspl.es
Mon May 5 19:45:30 CEST 2008


Hi Jens,

> In my VortexConnectionOnCloseFull handler, I want to check whether
> the  
> connection closed normally, or was abruptly terminated. (So I can
> pass  
> an error message up to my higher level code.)
> 
> I do this by checking vortex_connection_get_message. I assumed it  
> would be NULL if there were no error condition. But actually there
> are  
> at least three different values it can have during a normal close,
> so  
> I have to insert hard-coded checks for those three strings:
> 
>          const char *errorMsg =  
> vortex_connection_get_message(vortexConnection);
>          if( errorMsg ) {
>              if( 0!=strcmp(errorMsg,"close connection called")
>                       && 0!=strcmp(errorMsg,"connection properly  
> closed")
>                       && 0!=strcmp(errorMsg,"channel closed
> properly"))
>                  mySetError(errorMsg);
>          }
> 
> This is ugly, and very fragile if any of the error messages change  
> their wording in the future. There must be a better way to tell?
> (I've  
> tried checking vortex_connection_is_ok, but it always returns false.)

A long term solution is to work on adding a vortex_connection_status and
update all sources, specially to check all calls to
__vortex_connection_set_not_connected to configure a proper error code. 

Cheers!

> —Jens
-- 
Francis Brosnan Blazquez <francis at aspl.es>
Advanced Software Production Line, S.L.




More information about the Vortex mailing list