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

Jens Alfke jens at mooseyard.com
Sat May 3 02:48:42 CEST 2008


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.)

—Jens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1875 bytes
Desc: not available
Url : http://lists.aspl.es/pipermail/vortex/attachments/20080502/89a86d18/attachment.bin 


More information about the Vortex mailing list