Question how to constantly try a connection?

Slayer9x9

New member
Joined
Sep 12, 2008
Messages
2
Programming Experience
Beginner
Hey all, I'm new to these forums, and I hope you guys can help. x)

So, I'm not a n00b at coding (but I'm still sort-of a beginner - I know the basics) and I'm interested in the areas of socket programming.

The problem is that I'm trying to make a server that connects to a client on my computer, but I want the server to constantly try a connection. I tried using the Try - Catch method, but vb.net keeps bugging me about the connection.

Is there a way to tell the server to try a connection, and ignore all connection errors and try again?

Thanks in advance.:D
 
Heh, actually I figured it out...
It was indeed a simple Try...Catch.

What I originally did was:
VB.NET:
Public Sub Connect()
     Try
               tcpClient.Connect("some_host_name", some_port")
     Catch ex as Exception
               tcpClient.Connect("some_host_name", some_port")
     End Try
End Sub

After completing the "Try", I would constantly get a connection error on the "Catch" method.
However, all I had to do was this:
VB.NET:
Public Sub Connect()
TryAgain:    
     Try
               tcpClient.Connect("some_host_name", some_port")
     Catch ex as SocketException
               goto TryAgain
     End Try
End Sub

Thanks for your help, and I look forward to helping others as well.:D
 
Back
Top