Results 1 to 5 of 5

Thread: VB.net Program not receiving UDP packets

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2025
    Posts
    4

    Question VB.net Program not receiving UDP packets

    Hello

    Ten years ago I wrote a VS Visual Basic application to receive messages sent by my android smartphone in UPD on my PC.

    Today I'm trying to use this application again, but it's not receiving anything.

    I know that the android app works and sends requests because I receive them on my PC with an application like UDP Test Tool (https://udp-test-tool.informer.com).

    So the problem is on the PC side. I tried different examples of code to receive UDP packets, with or without thread, but without success.

    Here's an example:


    Code:
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
    
        'https://learn.microsoft.com/fr-fr/dotnet/framework/network-programming/using-udp-services
        Dim listenPort As Integer = 13000
        Dim listener As New UdpClient(listenPort)
        Dim groupEP As New IPEndPoint(IPAddress.Any, listenPort)
    
        Try
            While True
                Console.WriteLine("Waiting for broadcast")
                Dim bytes As Byte() = listener.Receive(groupEP)
                Console.WriteLine("Received broadcast from {groupEP} :")
                Dim receiveString As String = Encoding.ASCII.GetString(bytes)
                Label_Reception.Text = receiveString
            End While
    
        Catch ex As SocketException
            Console.WriteLine(ex.ToString())
        Finally
            listener.Close()
        End Try
    
    End Sub
    On the Windows Defender firewall, I authorized the receiving Visual Basic PC application to communicate (private network).

    On the Box side, I tried to open the port used, but I don't really know what to do.

    But to no avail, my application still receives nothing and I don't know what to do.

    That's why I'm asking for your help.

    thanks

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2025
    Posts
    4

    Re: VB.net Program not receiving UDP packets

    Thanks
    I will test this tomorrow monday.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2025
    Posts
    4

    Re: VB.net Program not receiving UDP packets

    Unfortunatly , this didn't change nothing.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,779

    Re: VB.net Program not receiving UDP packets

    Quote Originally Posted by Pierre_1965 View Post
    I know that the android app works and sends requests because I receive them on my PC with an application like UDP Test Tool (https://udp-test-tool.informer.com).
    Then the problem has to be with your application. I don't trust IPAddress.Any. Try using your PC's actual IP address first and see if that works.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2025
    Posts
    4

    Re: VB.net Program not receiving UDP packets

    Thanks Niya

    I solved my problem by disabling the firewall for the private network.

    It was the same problem with PC's actual IP instade of IPAddress.Any.

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