UdpClient ...can I make it time out?
Sometimes when I try to connect ...it takes a long time...
(seems like its slow in general)
is there a way to make it time out?
Heres the code im using...
VB Code:
Private Sub FindPlayer(ByVal IP As String, ByVal Port As Integer, ByVal Player As String)
Dim WS As New UdpClient
Try
'Dim Send As String
WS.Connect(IP, Port)
Dim Status As [Byte]() = Encoding.ASCII.GetBytes("\players\")
WS.Send(Status, Status.Length)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes As [Byte]() = WS.Receive(RemoteIpEndPoint)
Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
TextBox4.Text = returnData.ToString()
If InStr(returnData.ToString, Player) <> 0 Then
MsgBox("yes")
Else
MsgBox("No")
End If
WS.Close()
Catch Ex As Exception
MsgBox(Ex.ToString())
End Try
End Sub
Thanks