Click here to Skip to main content
15,888,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)

VB
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 '255.255.255.255 for local network
    Private sendingClient As UdpClient
    Private Sub SendMsgButton_Click() Handles SendMsgButton.Click
        RecipientIPAddress = IPToSendToTextbox.text 'for example, 192.168.1.99
        InitializeSender()
    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()
        form1.data = Encoding.ASCII.GetBytes(form1.toSend)
        form1.sendingClient.Send(form1.data, form1.data.Length)
    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?

Thanks.
Posted

1 solution

Any port number not in use should work, your problem might be a firewall blocking the traffic.
 
Share this answer
 
Comments
[no name] 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900