Home Forums Support Automatically reconnect

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4217
    Anonymous
    Inactive

    Hi,

    I am currently using the library for some simple distributed application, and for this i wanted it to connect and reconnect automatically when it gets disconnected. For some reason i’m not entirely sure how to implement this as the most obvious tries (by checking the current state etc.) failed.

    The only working solution i found was this: http://pastebin.com/bMsAKNpM and the only reason why this works is, because it spamms connections, untill it gets an exception that the connection (made by the previous execution) is already open.

    Any better ways to archieve this?

    Kind regards,
    Michael

    #4218
    Anonymous
    Inactive

    Because of how IP/TCP connections work it is not possible to know before attempting to send data that there is an error. The correct approach is to maintain a connection reference and, if when used, there is an error recreate the connection.

    An alternative for this is to always use the GetConnection(ConnectionInfo) method that performs a connection test, which if it fails will reestablish the connection.

    Regards,
    Marc

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.