|
-
Feb 22nd, 2003, 12:12 AM
#1
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
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 23rd, 2003, 12:58 AM
#2
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 23rd, 2003, 09:19 PM
#3
Fanatic Member
im gonna have to do some winsock soon, i looked at it before and it all confused me. anyways i think i saw on system.net.sockets.socket that they have a .BeginConnect method that works asynchronously and then you provide a callback function that would in turn call .EndConnect
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Feb 24th, 2003, 12:04 AM
#4
hmmm...thanks
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|