Hello i have been trying to make a program that should restart my server if it crashes. Just some few problems... it won't work.
Imports System.Net.Sockets
Imports System.Text
Module Module1
Sub Main()
Console.Title = "Shifty Server Keeper"
Dim clientSocket As New System.Net.Sockets.TcpClient()
While clientSocket.Connected = False
Try
clientSocket.Connect("127.0.0.1", 27015)
Console.WriteLine("Running")
Catch ex As Exception
Console.WriteLine("Crashed")
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("ssrcds")
For Each p As Process In pProcess
p.Kill()
Next
System.Diagnostics.Process.Start("C:\....")
End Try
End While
While clientSocket.Connected = True
End While
End Sub
End Module
My problem is that when it notices the program runs, it won't do the process again, and just stop watching for the server crash. Please tell me a way to make it repeat :)
I tryet do a Do...Loop but i don't seem to do it right.