Results 1 to 4 of 4

Thread: UdpClient ...can I make it time out?

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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:
    1. Private Sub FindPlayer(ByVal IP As String, ByVal Port As Integer, ByVal Player As String)
    2.         Dim WS As New UdpClient
    3.         Try
    4.             'Dim Send As String
    5.             WS.Connect(IP, Port)
    6.             Dim Status As [Byte]() = Encoding.ASCII.GetBytes("\players\")
    7.             WS.Send(Status, Status.Length)
    8.  
    9.             Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
    10.             Dim receiveBytes As [Byte]() = WS.Receive(RemoteIpEndPoint)
    11.             Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
    12.             TextBox4.Text = returnData.ToString()
    13.             If InStr(returnData.ToString, Player) <> 0 Then
    14.                 MsgBox("yes")
    15.             Else
    16.                 MsgBox("No")
    17.             End If
    18.             WS.Close()
    19.         Catch Ex As Exception
    20.             MsgBox(Ex.ToString())
    21.         End Try
    22.     End Sub


    Thanks
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    anyone???
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    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.

  4. #4

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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
  •  



Click Here to Expand Forum to Full Width