Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET udp
Hi people

I know i've posted something similar to this before, but it's a completely different question.

The problem is, that with the following code, port 54545 does not work. The code is intended to send a message via the port variable to the IP address.
I want the code to be able to, for example, send a message to you, the one reading this, if you have the receiver program (which has to be anywhere in the world, providing you have a network connection)
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports System.Text
Public Class Form1
    Private Const port As Integer = 54545
    Dim RecipientIPAddress As String = Nothing ' for local network
    Private sendingClient As UdpClient
    Private Sub SendMsgButton_Click() Handles SendMsgButton.Click
        RecipientIPAddress = IPToSendToTextbox.text 'for example,
    End Sub
    Private Sub InitializeSender()
        sendingClient = New UdpClient(RecipientIPAddress, port)
        sendingClient.EnableBroadcast = True
    End Sub
    Public toSend As String
    Dim data() As Byte
    Public Shared Sub go() = Encoding.ASCII.GetBytes(form1.toSend)
    End Sub
   end class

Things I know about the problem:
  • UDPClient Ports range from 5454[2-5]
  • Port 80 doesn't work
Does anyone know a port number that will work for this?

Posted 11-Apr-13 0:13am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Any port number not in use should work, your problem might be a firewall blocking the traffic.
Rixterz123 at 11-Apr-13 5:26am
Thanks, but i'll wait for some more replies before i look into it.
I have a code that puts my program in the exceptions list in the firewall; if I run this, will it allow the port?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 455
1 Sergey Alexandrovich Kryukov 445
2 Maciej Los 290
3 ProgramFOX 275
4 CHill60 225
0 OriginalGriff 550
1 Sergey Alexandrovich Kryukov 470
2 Maciej Los 310
3 ProgramFOX 275
4 Peter Leow 250

Advertise | Privacy | Mobile
Web03 | 2.8.150331.1 | Last Updated 11 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100