Skip to content

Connection Attempt Timeout #42

Answered by jchristn
Exergist asked this question in Q&A
Feb 18, 2021 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

Hi @Exergist there is a parameter is SimpleTcpClient.Settings called ConnectTimeoutSeconds which should accomplish the stated goal of having a connection timeout.

You could wrap client.Connect() in a for loop to specify the number of retries, like you have above, but instead of managing a variable for the total number of seconds, you could just manage a variable for the number of retries.

The exception thrown by Connect() if it's unable to connect is a SocketException - might be easier to just catch (SocketException) than to parse the message. It's unlikely to be thrown for much else.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Exergist
Comment options

@jchristn
Comment options

@Exergist
Comment options

@jchristn
Comment options

@Exergist
Comment options

Answer selected by Exergist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants