Results 1 to 4 of 4

Thread: udp send and receive

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    5

    udp send and receive

    hi all, i have a program that needs bi directional comunication with a device i bought,
    i can send udp commands to it, thats working like a charm, but when i try to receive data from it i can only see the data that im sending, not the response,
    my code:
    Code:
     Public udpClient As New UdpClient(11000)
     Public udpClient2 As New UdpClient(52380)
     Private Sub Hoofd_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            udpClient.Connect("255.255.255.255", 52380)
            udp_scan.Start()
            udpClient2.Client.ReceiveTimeout = 1000
        End Sub
    
    Private Sub udp_scan_Tick(sender As Object, e As EventArgs) Handles udp_scan.Tick
            info_label.Text = "ZOEKEN..."
            Dim sendbytes = New Byte() {&H2, &H45, &H4E, &H51, &H3A, &H6E, &H65, &H74, &H77, &H6F, &H72, &H6B, &HFF, &H3}
            udpClient.Send(sendbytes, sendbytes.Length)
            doread()
        End Sub
    
    Function doread()
            Try
                Dim iepRemoteEndPoint As IPEndPoint = New _
                IPEndPoint(IPAddress.Any, 52380)
                Dim strMessage As String = String.Empty
                Do
    
    
                    Dim bytRecieved As Byte() =
                   udpClient2.Receive(iepRemoteEndPoint)
                    strMessage = Encoding.ASCII.GetString(bytRecieved)
    
                    Console.WriteLine("This is the message you received: " _
                   + strMessage)
    
                Loop While (strMessage <> "exit")
                udpClient2.Close()
    
    
            Catch e As Exception
    
                Console.WriteLine(e.ToString())
            End Try
            Return 0
        End Function

    in wireshark i can see both the data i send and the response, in my program i only receive what im sending not the response.
    i added the full project in attachments
    Who can help me ?
    Last edited by Shaggy Hiker; Oct 18th, 2020 at 09:09 AM. Reason: Added CODE tags.

Tags for this Thread

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